]> Git Repo - linux.git/commitdiff
jfs: xattr: check invalid xattr size more strictly
authorArtem Sadovnikov <[email protected]>
Sat, 5 Oct 2024 10:06:57 +0000 (10:06 +0000)
committerDave Kleikamp <[email protected]>
Tue, 29 Oct 2024 22:17:43 +0000 (17:17 -0500)
Commit 7c55b78818cf ("jfs: xattr: fix buffer overflow for invalid xattr")
also addresses this issue but it only fixes it for positive values, while
ea_size is an integer type and can take negative values, e.g. in case of
a corrupted filesystem. This still breaks validation and would overflow
because of implicit conversion from int to size_t in print_hex_dump().

Fix this issue by clamping the ea_size value instead.

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Cc: [email protected]
Signed-off-by: Artem Sadovnikov <[email protected]>
Signed-off-by: Dave Kleikamp <[email protected]>
fs/jfs/xattr.c

index 0fb05e314edf606f7b1265aee92a97403587944b..24afbae87225a770e4701ce9f408bd7c87de18d8 100644 (file)
@@ -559,7 +559,7 @@ static int ea_get(struct inode *inode, struct ea_buffer *ea_buf, int min_size)
 
       size_check:
        if (EALIST_SIZE(ea_buf->xattr) != ea_size) {
-               int size = min_t(int, EALIST_SIZE(ea_buf->xattr), ea_size);
+               int size = clamp_t(int, ea_size, 0, EALIST_SIZE(ea_buf->xattr));
 
                printk(KERN_ERR "ea_get: invalid extended attribute\n");
                print_hex_dump(KERN_ERR, "", DUMP_PREFIX_ADDRESS, 16, 1,
This page took 0.058542 seconds and 4 git commands to generate.