]> www.infradead.org Git - nvme.git/commit
usb: gadget: printer: fix races against disable
authorOliver Neukum <oneukum@suse.com>
Thu, 20 Jun 2024 11:40:26 +0000 (13:40 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Jun 2024 17:33:22 +0000 (19:33 +0200)
commite587a7633dfee8987a999cf253f7c52a8e09276c
treebf72d2ac0cd5eb70f8d9f1681bef63b33a273fa0
parentfd80731e5e9d1402cb2f85022a6abf9b1982ec5f
usb: gadget: printer: fix races against disable

printer_read() and printer_write() guard against the race
against disable() by checking the dev->interface flag,
which in turn is guarded by a spinlock.
These functions, however, drop the lock on multiple occasions.
This means that the test has to be redone after reacquiring
the lock and before doing IO.

Add the tests.

This also addresses CVE-2024-25741

Fixes: 7f2ca14d2f9b9 ("usb: gadget: function: printer: Interface is disabled and returns error")
Cc: stable <stable@kernel.org>
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Link: https://lore.kernel.org/r/20240620114039.5767-1-oneukum@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_printer.c