This is a note to let you know that I've just added the patch titled usb: mon: make mmapped memory read only to the 6.0-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: usb-mon-make-mmapped-memory-read-only.patch and it can be found in the queue-6.0 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From a659daf63d16aa883be42f3f34ff84235c302198 Mon Sep 17 00:00:00 2001 From: Tadeusz Struk <tadeusz.struk@xxxxxxxxxx> Date: Mon, 19 Sep 2022 14:59:57 -0700 Subject: usb: mon: make mmapped memory read only From: Tadeusz Struk <tadeusz.struk@xxxxxxxxxx> commit a659daf63d16aa883be42f3f34ff84235c302198 upstream. Syzbot found an issue in usbmon module, where the user space client can corrupt the monitor's internal memory, causing the usbmon module to crash the kernel with segfault, UAF, etc. The reproducer mmaps the /dev/usbmon memory to user space, and overwrites it with arbitrary data, which causes all kinds of issues. Return an -EPERM error from mon_bin_mmap() if the flag VM_WRTIE is set. Also clear VM_MAYWRITE to make it impossible to change it to writable later. Cc: "Dmitry Vyukov" <dvyukov@xxxxxxxxxx> Cc: stable <stable@xxxxxxxxxx> Fixes: 6f23ee1fefdc ("USB: add binary API to usbmon") Suggested-by: PaX Team <pageexec@xxxxxxxxxxx> # for the VM_MAYRITE portion Link: https://syzkaller.appspot.com/bug?id=2eb1f35d6525fa4a74d75b4244971e5b1411c95a Reported-by: syzbot+23f57c5ae902429285d7@xxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Tadeusz Struk <tadeusz.struk@xxxxxxxxxx> Link: https://lore.kernel.org/r/20220919215957.205681-1-tadeusz.struk@xxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/usb/mon/mon_bin.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c @@ -1268,6 +1268,11 @@ static int mon_bin_mmap(struct file *fil { /* don't do anything here: "fault" will set up page table entries */ vma->vm_ops = &mon_bin_vm_ops; + + if (vma->vm_flags & VM_WRITE) + return -EPERM; + + vma->vm_flags &= ~VM_MAYWRITE; vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; vma->vm_private_data = filp->private_data; mon_bin_vma_open(vma); Patches currently in stable-queue which might be from tadeusz.struk@xxxxxxxxxx are queue-6.0/usb-mon-make-mmapped-memory-read-only.patch