diff options
| author | Shahriyar Jalayeri <[email protected]> | 2026-07-28 08:55:39 +0200 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-08-27 15:01:02 -0600 |
| commit | 561ae28cb56a082cfa90c1c421c4955bc215470b (patch) | |
| tree | a066a3d7673ecfffc564896495c730ad136b563f /test | |
| parent | fdfe2ec48d5c1c2ed03073d73edd3fdd3fe1ffa1 (diff) | |
fs/squashfs: fix integer overflow in directory table allocation
sqfs_read_directory_table() allocates the directory table with
malloc(metablks_count * SQFS_METADATA_BLOCK_SIZE). metablks_count is an
int and SQFS_METADATA_BLOCK_SIZE is 8192, so the multiply is evaluated in
int and wraps for metablks_count >= 2^19. metablks_count comes from the
attacker-controlled superblock (sqfs_count_metablks() grows it by one per
2-byte metadata header), so a crafted image under-allocates the buffer
while the fill loop still writes metablks_count metadata blocks into it,
a heap out-of-bounds write. It is reached by listing or reading the image
(sqfsls / sqfsload). The position list allocation on the next line has the
same unchecked-multiply shape.
Size both allocations with __builtin_mul_overflow() and reject the image
on overflow, as the disk-read buffers earlier in the same function already
do. Set the error return when either allocation fails so the caller does
not proceed with a NULL directory table.
Fixes: c51006130370 ("fs/squashfs: new filesystem")
Signed-off-by: Shahriyar Jalayeri <[email protected]>
Reviewed-by: Richard Genoud <[email protected]>
Diffstat (limited to 'test')
0 files changed, 0 insertions, 0 deletions
