Direct naar de inhoud
⚡ Kritieke cyberalerts voor jouw sector & systemen — direct in je inbox. Aanmelden →
CVE's Videos Dagbriefing

← Terug naar CVE-database

CVE-2025-38016

HIGH · 8.8 CVSS Gepubliceerd:

Beschrijving NL

In de Linux kernel is de volgende kwetsbaarheid verholpen:

HID: bpf: verzending afbreken indien apparaat vernietigd

De huidige HID bpf-implementatie gaat ervan uit dat er geen outputrapport/verzoek
doorlopen nadat HID_bpf_destroy_device() is aangeroepen. Dit leidt
aan een bug die het loskoppelen van bepaalde soorten HID-apparaten veroorzaakt een schoon-
om toegang te krijgen tot SRCU. De bug was eerder een verborgen fout tot een
recente x86 percpu-wijziging [1] zorgde ervoor dat het toegang kreeg tot pagina's die niet aanwezig waren. De bug wordt geactiveerd als aan de onderstaande voorwaarden wordt voldaan:

A) een apparaat onder de driver heeft enkele LED's aan
B) hid_ll_driver->verzoek() is niet geïmplementeerd (bijv. logitech-djreceiver)

Als aan voorwaarde A is voldaan, wordt hidinput_led_worker() altijd ingepland *na*
hid_bpf_destroy_device(). hid_destroy_device
`HID_bpf_destroy_device
` cleanup_srcu_struct(&hdev->bpf.srcu)
` HID_remove_device
` ... ` led_classdev_unregister
` led_trigger_set(led_cdev, NULL)
` LED_set_Brightness(LED_cdev, LED_off)
` ... ` input_inject_event
` input_event_dispose
` hidinput_input_event
` schedule_work(&HID->led_work) [hidinput_led_worker]

Dit is prima als niet aan voorwaarde B is voldaan, waarbij hidinput_led_worker()
calls hid_ll_driver->request(). Dit is het geval voor de meeste HID-chauffeurs,
die het implementeren of de generieke van usbhid gebruiken. De bestuurder zelf
of een onderliggende bestuurder zal dan de verwerking van het verzoek afbreken. Anders probeert hidinput_led_worker() hid_hw_output_report() en leads
aan de bug. hidinput_led_worker
`HID_hw_output_report
` dispatch_hid_bpf_output_report
` srcu_read_lock(&hdev->bpf.srcu)
` srcu_read_unlock(&hdev->bpf.srcu, idx)

De bug bestaat al sinds de introductie [2] van
dispatch_hid_bpf_output_report(). Dezelfde bug bestaat echter ook in
dispatch_hid_bpf_raw_requests(), en ik heb het gereproduceerd (geen zichtbaar effect)
vanwege het ontbreken van [1], maar bevestigd bpf.destroyed == 1) de bug
tegen de commit (d.w.z. de Fixes:) die de functie introduceerde. Dit is
omdat hidinput_led_worker() terugvalt op hid_hw_raw_request() wanneer
hid_ll_driver->output_report() is niet geïmplementeerd (bijv. logitech-
djreceiver). hidinput_led_worker
`HID_hw_output_REPORT: -ENOSYS
`HID_hw_RAW_request
` dispatch_hid_bpf_raw_requests
` srcu_read_lock(&hdev->bpf.srcu)
` srcu_read_unlock(&hdev->bpf.srcu, idx)

Los het probleem op door vroeg terug te keren in de twee genoemde functies als
hid_bpf is gemarkeerd als vernietigd. Hoewel
dispatch_hid_bpf_device_event() verwerkt invoergebeurtenissen en er is geen
bewijs dat het na de vernietiging kan worden genoemd, dezelfde controle, als
een vangnet, wordt er ook aan toegevoegd om de consistentie tussen alle
verzendfuncties. De impact van de bug op andere architecturen is onduidelijk. Zelfs als het werkt
als een verborgen fout, is dit nog steeds gevaarlijk omdat het corrumpeert
wat er ook op het door SRCU berekende adres staat. Aldus CC'ing de stal
lijst. [1]: commit 9d7de2aa8b41 ("x86/percpu/64: Gebruik relatieve percpu-offsets")
[2]: commit 9286675a2aed ("HID: bpf: voeg HID-BPF-haken toe voor
hid_hw_output_report")

Origineel (Engels) tonen

In the Linux kernel, the following vulnerability has been resolved:

HID: bpf: abort dispatch if device destroyed

The current HID bpf implementation assumes no output report/request will
go through it after hid_bpf_destroy_device() has been called. This leads
to a bug that unplugging certain types of HID devices causes a cleaned-
up SRCU to be accessed. The bug was previously a hidden failure until a
recent x86 percpu change [1] made it access not-present pages.

The bug will be triggered if the conditions below are met:

A) a device under the driver has some LEDs on
B) hid_ll_driver->request() is uninplemented (e.g., logitech-djreceiver)

If condition A is met, hidinput_led_worker() is always scheduled *after*
hid_bpf_destroy_device().

hid_destroy_device
` hid_bpf_destroy_device
` cleanup_srcu_struct(&hdev->bpf.srcu)
` hid_remove_device
` ...
` led_classdev_unregister
` led_trigger_set(led_cdev, NULL)
` led_set_brightness(led_cdev, LED_OFF)
` ...
` input_inject_event
` input_event_dispose
` hidinput_input_event
` schedule_work(&hid->led_work) [hidinput_led_worker]

This is fine when condition B is not met, where hidinput_led_worker()
calls hid_ll_driver->request(). This is the case for most HID drivers,
which implement it or use the generic one from usbhid. The driver itself
or an underlying driver will then abort processing the request.

Otherwise, hidinput_led_worker() tries hid_hw_output_report() and leads
to the bug.

hidinput_led_worker
` hid_hw_output_report
` dispatch_hid_bpf_output_report
` srcu_read_lock(&hdev->bpf.srcu)
` srcu_read_unlock(&hdev->bpf.srcu, idx)

The bug has existed since the introduction [2] of
dispatch_hid_bpf_output_report(). However, the same bug also exists in
dispatch_hid_bpf_raw_requests(), and I've reproduced (no visible effect
because of the lack of [1], but confirmed bpf.destroyed == 1) the bug
against the commit (i.e., the Fixes:) introducing the function. This is
because hidinput_led_worker() falls back to hid_hw_raw_request() when
hid_ll_driver->output_report() is uninplemented (e.g., logitech-
djreceiver).

hidinput_led_worker
` hid_hw_output_report: -ENOSYS
` hid_hw_raw_request
` dispatch_hid_bpf_raw_requests
` srcu_read_lock(&hdev->bpf.srcu)
` srcu_read_unlock(&hdev->bpf.srcu, idx)

Fix the issue by returning early in the two mentioned functions if
hid_bpf has been marked as destroyed. Though
dispatch_hid_bpf_device_event() handles input events, and there is no
evidence that it may be called after the destruction, the same check, as
a safety net, is also added to it to maintain the consistency among all
dispatch functions.

The impact of the bug on other architectures is unclear. Even if it acts
as a hidden failure, this is still dangerous because it corrupts
whatever is on the address calculated by SRCU. Thus, CC'ing the stable
list.

[1]: commit 9d7de2aa8b41 ("x86/percpu/64: Use relative percpu offsets")
[2]: commit 9286675a2aed ("HID: bpf: add HID-BPF hooks for
hid_hw_output_report")

Vendors

Linux

Affected products

Linux Kernel

References