summaryrefslogtreecommitdiff
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorPiyush Paliwal <[email protected]>2026-06-12 13:24:23 +0530
committerTom Rini <[email protected]>2026-08-28 08:55:57 -0600
commit73ada2f433a99fb2f443bb76268f5ab023b11868 (patch)
tree4db4be420c2a959ae8c3da9d2678459f296cffd0 /scripts/checkpatch.pl
parent5ca1a73c7d3064582498a8aa96c29e714402a6d3 (diff)
fs/squashfs: bound the inode table walk in sqfs_find_inode()
sqfs_find_inode() walks the decompressed inode table advancing "offset += sqfs_inode_size(base, ...)" with no check that offset stays within the table (metablks_count * SQFS_METADATA_BLOCK_SIZE). All sizes come from the on-disk image, including the unbounded extended-directory (LDIR) index walk and the regular-file block-list term in sqfs_inode_size(). A crafted image makes base run off the end of the buffer -> out-of-bounds read / SEGV, reachable simply by listing the image (ls/sqfsls) or any operation that resolves a path. The earlier fix 3fb1df1e5 ("squashfs: Check sqfs_find_inode() return value") only added NULL checks at the call sites; it did not add the missing internal bound, so the wild read still occurs before the function can return. c8e929e5 fixed only the symlink case of sqfs_inode_size(), leaving the LDIR index walk unbounded. Thread the inode table size from sqfs_read_inode_table() through the squashfs_dir_stream to sqfs_find_inode(), and: - reject an inode whose base header does not fit in the table; - pass the remaining byte count to sqfs_inode_size() and validate every variable-length read (LDIR index list, REG/LREG block list, symlink, device/ipc inodes) against it, with overflow-checked arithmetic; - reject an inode whose computed size leaves the table. Found by fuzzing the sandbox (CONFIG_ASAN) sqfsls/sqfsload with mutated images. Before: SEGV in sqfs_find_inode (sqfs_inode.c) and in sqfs_inode_size() LDIR walk. After: malformed images are rejected cleanly; 2000 fuzz iterations produce no crash and the valid-image path is unchanged. Fixes: c51006130370 ("fs/squashfs: new filesystem") Cc: [email protected] Signed-off-by: Piyush Paliwal <[email protected]> Reviewed-by: Richard Genoud <[email protected]>
Diffstat (limited to 'scripts/checkpatch.pl')
0 files changed, 0 insertions, 0 deletions