]> git.baikalelectronics.ru Git - kernel.git/commit
usb: mon: make mmapped memory read only
authorTadeusz Struk <tadeusz.struk@linaro.org>
Mon, 19 Sep 2022 21:59:57 +0000 (14:59 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 15 Oct 2022 05:54:38 +0000 (07:54 +0200)
commit5422e6fbb18ae6749851d1e0f5b4a5e7e0672b2a
treed86bc341fb352e56fa146bb95a8d86b089900d2a
parentcf500312420d449862ab3d83dd005d55b123c487
usb: mon: make mmapped memory read only

commit 6b5cc2d6ab771f5f2b5a4edc2fc91112514baa14 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@google.com>
Cc: stable <stable@kernel.org>
Fixes: 904509fcee0d ("USB: add binary API to usbmon")
Suggested-by: PaX Team <pageexec@freemail.hu> # for the VM_MAYRITE portion
Link: https://syzkaller.appspot.com/bug?id=2eb1f35d6525fa4a74d75b4244971e5b1411c95a
Reported-by: syzbot+23f57c5ae902429285d7@syzkaller.appspotmail.com
Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Link: https://lore.kernel.org/r/20220919215957.205681-1-tadeusz.struk@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/mon/mon_bin.c