In the Linux kernel, the following vulnerability has been resolved: hwmon: (corsair-cpro) Create debugfs entries after hwmon registration ccp_debugfs_init() registers debugfs files whose private data is the devm allocated ccp. Он запускается до hwmon_device_register_with_info (), поэтому, когда регистрация не удается, ccp_probe () возвращается с файлами все еще на месте. Ядро HID затем освобождает ccp, а ccp_remove() не вызывается для неудачного зонда, поэтому ничто не удаляет их позже.
Чтение одного из файлов лишает ссылки освободившийся указатель. Создайте записи debugfs только после того, как устройство hwmon было зарегистрировано, поэтому ни один сбойный путь не может оставить их позади. Две версии остаются там, где они есть.
Они отправляют команды USB, не удерживая ccp->mutex, что безопасно только до тех пор, пока ничто другое не может вызвать send_usb_cmd (); как только устройство hwmon зарегистрировано, его обратные вызовы могут делать это одновременно. Только создание debugfs движется, и сообщается, какие запросы были успешными.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: hwmon: (corsair-cpro) Create debugfs entries after hwmon registration ccp_debugfs_init() registers debugfs files whose private data is the devm allocated ccp. It runs before hwmon_device_register_with_info(), so when that registration fails, ccp_probe() returns with the files still in place. The HID core then frees ccp, and ccp_remove() is not called for a failed probe, so nothing removes them later either. Reading one of the files dereferences the freed pointer. Create the debugfs entries only after the hwmon device has been registered, so no failing path can leave them behind. The two version queries stay where they are. They send USB commands without holding ccp->mutex, which is only safe as long as nothing else can call send_usb_cmd(); once the hwmon device is registered its callbacks can do so concurrently. Only the debugfs creation moves, and it is told which queries succeeded.