Skip to content

Commit 72e544b

Browse files
pchelkin91akpm00
authored andcommitted
squashfs: harden sanity check in squashfs_read_xattr_id_table
While mounting a corrupted filesystem, a signed integer '*xattr_ids' can become less than zero. This leads to the incorrect computation of 'len' and 'indexes' values which can cause null-ptr-deref in copy_bio_to_actor() or out-of-bounds accesses in the next sanity checks inside squashfs_read_xattr_id_table(). Found by Linux Verification Center (linuxtesting.org) with Syzkaller. Link: https://lkml.kernel.org/r/[email protected] Fixes: 506220d ("squashfs: add more sanity checks in xattr id lookup") Reported-by: <[email protected]> Signed-off-by: Fedor Pchelkin <[email protected]> Signed-off-by: Alexey Khoroshilov <[email protected]> Cc: Phillip Lougher <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 6f28a26 commit 72e544b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/squashfs/xattr_id.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ __le64 *squashfs_read_xattr_id_table(struct super_block *sb, u64 table_start,
7676
/* Sanity check values */
7777

7878
/* there is always at least one xattr id */
79-
if (*xattr_ids == 0)
79+
if (*xattr_ids <= 0)
8080
return ERR_PTR(-EINVAL);
8181

8282
len = SQUASHFS_XATTR_BLOCK_BYTES(*xattr_ids);

0 commit comments

Comments
 (0)