fs/squashfs: fix two out-of-bounds reads on crafted images
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 3 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | fs/squashfs: bound the inode table walk in sqfs_find_inode()fs/ fs/ fs/ | +110 | 0 replies | |
| 2/2 | fs/squashfs: bound fragment offset/size in sqfs_read_nest()fs/ | +24 | 0 replies |
Reviews trailers per patch
None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Richard Genoud |
|---|---|
| Series | R-b |
| 1/2 | |
| 2/2 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/2] fs/squashfs: fix two out-of-bounds reads on crafted images
Two independent out-of-bounds reads in the SquashFS driver, both reachable by pointing U-Boot at an attacker-supplied image (e.g. ls/load on a crafted USB/SD/netboot rootfs). Either one crashes the bootloader (DoS); patch 2 can also copy adjacent heap memory into the loaded file (information disclosure).
1/2 sqfs_find_inode()/sqfs_inode_size() walk the decompressed inode table
using on-disk sizes with no check that the cursor stays inside the buffer -> wild read / SEGV, e.g. from a simple "ls".
2/2 sqfs_read_nest() uses the on-disk fragment offset as an unbounded
source index into the fragment block -> out-of-bounds heap read when loading a fragment-backed file.
Both were found by fuzzing the sandbox build (CONFIG_ASAN) of sqfsls/sqfsload with mutated images. With the fixes, the crashing inputs are rejected cleanly, 2000 fuzz iterations produce no further crashes, and the valid-image path is unchanged.
These are distinct from the 2024 SquashFS CVE cluster (CVE-2024-57254..57259, fixed in 2025.01-rc1) and from the sqfs_frag_lookup() fix (e365a269df5): the earlier work added NULL checks at the callers and fixed the symlink-size and fragment-table paths, but left these inode-table-walk and fragment-data paths unbounded.
The two patches are independent and can be applied in either order.
Piyush Paliwal (2):
fs/squashfs: bound the inode table walk in sqfs_find_inode() fs/squashfs: bound fragment offset/size in sqfs_read_nest()
fs/squashfs/sqfs.c | 50 ++++++++++++---- fs/squashfs/sqfs_filesystem.h | 6 +- fs/squashfs/sqfs_inode.c | 106 +++++++++++++++++++++++++++++----- 3 files changed, 134 insertions(+), 28 deletions(-)
Signature · 1 line
2.41.0