diff options
| author | Pranav Rajendran <[email protected]> | 2026-08-15 23:01:14 +0100 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-08-27 15:00:03 -0600 |
| commit | fc557ef9fe116b3245265629cf1d3ab4ac7a480c (patch) | |
| tree | f7fdefe4cdb6e2c9a8c742d737a885f8e92fa02b /scripts/basic | |
| parent | 964ad5b5c91b7be56e443e899d7f873e6aa8c9fc (diff) | |
fs/squashfs: bound fragment table accesses in sqfs_frag_lookup()
sqfs_frag_lookup() validates its fragment index only against
sblk->fragments, which is read from the image superblock and is
therefore under the control of whoever supplies the image. Every
buffer access derived from that index is then made without checking
it against the size of the buffer actually read from the device:
- the fragment index table entry at 'table_offset + block *
sizeof(u64)' can be read past the end of 'table', as 'block' is
inode_fragment_index / SQFS_MAX_ENTRIES and has no upper bound;
- the metadata block header and payload are read from
'metadata_buffer' at 'table_offset', but that buffer is sized from
start_block, which comes from the unvalidated index table entry
above. A start_block just below sblk->fragment_table_start yields a
single-block buffer while SQFS_METADATA_SIZE(header) may be up to
SQFS_METADATA_BLOCK_SIZE, so both the decompression source and the
memcpy() source can run past the end of the buffer;
- 'entries' is allocated with SQFS_METADATA_BLOCK_SIZE bytes but only
partially filled, so entries[offset] can read uninitialised heap
memory when the metadata block holds fewer than offset + 1 entries.
Compute the size of both buffers explicitly, rejecting the
multiplication overflow the way sqfs_read_directory_table() already
does, and check each access against it. Also track how much of
'entries' was populated and reject an index beyond that.
A crafted SquashFS image can trigger all three cases, either crashing
U-Boot or feeding adjacent heap contents into the fragment entry that
the following data read is based on.
Fixes: c51006130370 ("fs/squashfs: new filesystem")
Signed-off-by: Pranav Rajendran <[email protected]>
Reviewed-by: Richard Genoud <[email protected]>
Diffstat (limited to 'scripts/basic')
0 files changed, 0 insertions, 0 deletions
