Files
linux/fs
Rand Deeb 7fcbf78962 fs/jfs: Prevent integer overflow in AG size calculation
The JFS filesystem calculates allocation group (AG) size using 1 <<
l2agsize in dbExtendFS(). When l2agsize exceeds 31 (possible with >2TB
aggregates on 32-bit systems), this 32-bit shift operation causes undefined
behavior and improper AG sizing.

On 32-bit architectures:
- Left-shifting 1 by 32+ bits results in 0 due to integer overflow
- This creates invalid AG sizes (0 or garbage values) in
sbi->bmap->db_agsize
- Subsequent block allocations would reference invalid AG structures
- Could lead to:
  - Filesystem corruption during extend operations
  - Kernel crashes due to invalid memory accesses
  - Security vulnerabilities via malformed on-disk structures

Fix by casting to s64 before shifting:
bmp->db_agsize = (s64)1 << l2agsize;

This ensures 64-bit arithmetic even on 32-bit architectures. The cast
matches the data type of db_agsize (s64) and follows similar patterns in
JFS block calculation code.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Rand Deeb <rand.sec96@gmail.com>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
2025-02-20 09:37:35 -06:00
..
2024-12-05 12:31:40 +01:00
2024-12-03 10:40:36 +01:00
2024-08-21 22:32:58 +02:00
2025-02-07 10:27:24 +01:00
2025-01-27 19:25:45 -05:00
2024-11-03 01:28:06 -05:00
2024-12-09 11:34:29 +01:00
2024-12-17 09:16:11 +01:00
2024-11-03 01:28:06 -05:00
2024-11-03 01:28:06 -05:00
2024-10-21 16:29:38 +02:00
2024-10-21 16:29:38 +02:00
2025-01-09 16:58:54 +01:00
2025-01-09 16:58:52 +01:00
2025-02-07 10:27:28 +01:00
2024-11-03 01:28:07 -05:00
2024-11-03 01:28:06 -05:00
2025-01-25 20:22:31 -08:00
2024-11-03 01:28:06 -05:00
2024-11-03 01:28:06 -05:00