В ядре Linux устранена следующая уязвимость:
USB: гаджет: f_hid: исправить время жизни f_hidg против cdev
Время жизни встроенной структуры cdev неправильно привязано к
включающая структура f_hidg, поэтому существует использование после освобождения, если /dev/hidgN
остается открытым, пока гаджет удаляется.
Это можно легко воспроизвести с помощью примеров программ из libusbgx (например,
краткость - работа напрямую через configfs эквивалентна):
гаджет спрятан
exec 3<> /dev/hidg0
гаджет-vid-pid-remove
исполнитель 3<&-
Подключите существующее устройство к struct f_hidg и используйте
cdev_device_{add,del}() помощники. Это меняет время жизни
объект устройства, соответствующий структуре f_hidg, но учтите, что он все равно добавляется
и одновременно удалил.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: usb: gadget: f_hid: fix f_hidg lifetime vs cdev The embedded struct cdev does not have its lifetime correctly tied to the enclosing struct f_hidg, so there is a use-after-free if /dev/hidgN is held open while the gadget is deleted. This can readily be replicated with libusbgx's example programs (for conciseness - operating directly via configfs is equivalent): gadget-hid exec 3<> /dev/hidg0 gadget-vid-pid-remove exec 3<&- Pull the existing device up in to struct f_hidg and make use of the cdev_device_{add,del}() helpers. This changes the lifetime of the device object to match struct f_hidg, but note that it is still added and deleted at the same time.