Skip to content

Commit d9f9d96

Browse files
Artem Sadovnikovkleikamp
authored andcommitted
jfs: xattr: check invalid xattr size more strictly
Commit 7c55b78 ("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]>
1 parent 839f102 commit d9f9d96

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/jfs/xattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ static int ea_get(struct inode *inode, struct ea_buffer *ea_buf, int min_size)
559559

560560
size_check:
561561
if (EALIST_SIZE(ea_buf->xattr) != ea_size) {
562-
int size = min_t(int, EALIST_SIZE(ea_buf->xattr), ea_size);
562+
int size = clamp_t(int, ea_size, 0, EALIST_SIZE(ea_buf->xattr));
563563

564564
printk(KERN_ERR "ea_get: invalid extended attribute\n");
565565
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_ADDRESS, 16, 1,

0 commit comments

Comments
 (0)