Skip to content

Commit 7c55b78

Browse files
committed
jfs: xattr: fix buffer overflow for invalid xattr
When an xattr size is not what is expected, it is printed out to the kernel log in hex format as a form of debugging. But when that xattr size is bigger than the expected size, printing it out can cause an access off the end of the buffer. Fix this all up by properly restricting the size of the debug hex dump in the kernel log. Reported-by: [email protected] Cc: Dave Kleikamp <[email protected]> Link: https://lore.kernel.org/r/2024051433-slider-cloning-98f9@gregkh Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 77427e3 commit 7c55b78

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/jfs/xattr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,11 @@ static int ea_get(struct inode *inode, struct ea_buffer *ea_buf, int min_size)
557557

558558
size_check:
559559
if (EALIST_SIZE(ea_buf->xattr) != ea_size) {
560+
int size = min_t(int, EALIST_SIZE(ea_buf->xattr), ea_size);
561+
560562
printk(KERN_ERR "ea_get: invalid extended attribute\n");
561563
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_ADDRESS, 16, 1,
562-
ea_buf->xattr, ea_size, 1);
564+
ea_buf->xattr, size, 1);
563565
ea_release(inode, ea_buf);
564566
rc = -EIO;
565567
goto clean_up;

0 commit comments

Comments
 (0)