jfs: xattr: fix buffer overflow for invalid xattr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

commit 7c55b78818cfb732680c4a72ab270cc2d2ee3d0f upstream.

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: syzbot+9dfe490c8176301c1d06@xxxxxxxxxxxxxxxxxxxxxxxxx
Cc: Dave Kleikamp <shaggy@xxxxxxxxxx>
Link: https://lore.kernel.org/r/2024051433-slider-cloning-98f9@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 fs/jfs/xattr.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -570,9 +570,11 @@ static int ea_get(struct inode *inode, s
 
       size_check:
 	if (EALIST_SIZE(ea_buf->xattr) != ea_size) {
+		int size = min_t(int, EALIST_SIZE(ea_buf->xattr), ea_size);
+
 		printk(KERN_ERR "ea_get: invalid extended attribute\n");
 		print_hex_dump(KERN_ERR, "", DUMP_PREFIX_ADDRESS, 16, 1,
-				     ea_buf->xattr, ea_size, 1);
+				     ea_buf->xattr, size, 1);
 		ea_release(inode, ea_buf);
 		rc = -EIO;
 		goto clean_up;


Patches currently in stable-queue which might be from gregkh@xxxxxxxxxxxxxxxxxxx are

queue-4.19/serial-sc16is7xx-fix-bug-in-sc16is7xx_set_baud-when-.patch
queue-4.19/usb-gadget-f_fs-fix-race-between-aio_cancel-and-aio-.patch
queue-4.19/usb-class-cdc-wdm-fix-cpu-lockup-caused-by-excessive-log-messages.patch
queue-4.19/jfs-xattr-fix-buffer-overflow-for-invalid-xattr.patch
queue-4.19/xhci-apply-broken-streams-quirk-to-etron-ej188-xhci-host.patch
queue-4.19/mei-me-release-irq-in-mei_me_pci_resume-error-path.patch
queue-4.19/xhci-apply-reset-resume-quirk-to-etron-ej188-xhci-host.patch
queue-4.19/serial-sc16is7xx-replace-hardcoded-divisor-value-wit.patch




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux