CVE-2023-52478: HID: logitech-hidpp: Fix kernel crash on receiver USB disconnect

Published Feb 29, 2024
·
Updated

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

HID: logitech-hidpp: Fix kernel crash on receiver USB disconnect

hidppconnectevent() has four time-of-check vs time-of-use (TOCTOU) races when it races with itself.

hidppconnectevent() primarily runs from a workqueue but it also runs on probe() and if a "device-connected" packet is received by the hw when the thread running hidppconnectevent() from probe() is waiting on the hw, then a second thread running hidppconnectevent() will be started from the workqueue.

This opens the following races (note the below code is simplified):

1. Retrieving + printing the protocol (harmless race):

if (!hidpp->protocolmajor) { hidpprootgetprotocolversion() hidpp->protocolmajor = response.rap.params[0]; }

We can actually see this race hit in the dmesg in the abrt output attached to rhbz#2227968:

[ 3064.624215] logitech-hidpp-device 0003:046D:4071.0049: HID++ 4.5 device connected. [ 3064.658184] logitech-hidpp-device 0003:046D:4071.0049: HID++ 4.5 device connected.

Testing with extra logging added has shown that after this the 2 threads take turn grabbing the hw access mutex (sendmutex) so they ping-pong through all the other TOCTOU cases managing to hit all of them:

2. Updating the name to the HIDPP name (harmless race):

if (hidpp->name == hdev->name) { ... hidpp->name = newname; }

3. Initializing the powersupply class for the battery (problematic!):

hidppinitializebattery() { if (hidpp->battery.ps) return 0;

probebattery(); / Blocks, threads take turns executing this /

hidpp->battery.desc.properties = devmkmemdup(dev, hidppbatteryprops, cnt, GFPKERNEL);

hidpp->battery.ps = devmpowersupplyregister(&hidpp->hiddev->dev, &hidpp->battery.desc, cfg); }

4. Creating delayed inputdevice (potentially problematic):

if (hidpp->delayedinput) return;

hidpp->delayedinput = hidppallocateinput(hdev);

The really big problem here is 3. Hitting the race leads to the following sequence:

hidpp->battery.desc.properties = devmkmemdup(dev, hidppbatteryprops, cnt, GFPKERNEL);

hidpp->battery.ps = devmpowersupplyregister(&hidpp->hiddev->dev, &hidpp->battery.desc, cfg);

...

hidpp->battery.desc.properties = devmkmemdup(dev, hidppbatteryprops, cnt, GFPKERNEL);

hidpp->battery.ps = devmpowersupplyregister(&hidpp->hiddev->dev, &hidpp->battery.desc, cfg);

So now we have registered 2 power supplies for the same battery, which looks a bit weird from userspace's pov but this is not even the really big problem.

Notice how:

1. This is all devm-maganaged 2. The hidpp->battery.desc struct is shared between the 2 power supplies 3. hidpp->battery.desc.properties points to the result from the second devmkmemdup()

This causes a use after free scenario on USB disconnect of the receiver: 1. The last registered power supply class device gets unregistered 2. The memory from the last devmkmemdup() call gets freed, hidpp->battery.desc.properties now points to freed memory 3. The first registered power supply class device gets unregistered, this involves sending a remove uevent to userspace which invokes powersupplyuevent() to fill the uevent data 4. powersupplyuevent() uses hidpp->battery.desc.properties which now points to freed memory leading to backtraces like this one:

Sep 22 20:01:35 eric kernel: BUG: unable to handle page fault for address: ffffb2140e017f08 ... Sep 22 20:01:35 eric kernel: Workqueue: usbhubwq hubevent Sep 22 20:01:35 eric kernel: RIP: 0010:powersupplyuevent+0xee/0x1d0 ... Sep 22 20:01:35 eric kernel: ? asmexcpagefault+0x26/0x30 Sep 22 20:01:35 eric kernel: ? powersupplyuevent+0xee/0x1d0 Sep 22 20:01:35 eric kernel: ? powersupplyuevent+0x10d/0x1d0 Sep 22 20:01:35 eric kernel: devuevent+0x10f/0x2d0 Sep 22 20:01:35 eric kernel: kobjectueventenv+0x291/0x680 Sep 22 20:01:35 eric kernel: ---truncated---

Other sources

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

HID: logitech-hidpp: Fix kernel crash on receiver USB disconnect

The Linux kernel CVE team has assigned CVE-2023-52478 to this issue.

Upstream advisory: https://lore.kernel.org/linux-cve-announce/2024022921-CVE-2023-52478-c0a1@gregkh/T/#u

Red Hat

Affected Software

24 affected componentsFixes available
redhat/kernel<4.14.328
4.14.328
redhat/kernel<4.19.297
4.19.297
redhat/kernel<5.4.259
5.4.259
redhat/kernel<5.10.199
5.10.199
redhat/kernel<5.15.136
5.15.136
redhat/kernel<6.1.59
6.1.59
redhat/kernel<6.5.8
6.5.8
redhat/kernel<6.6
6.6
Linux Linux kernel<4.14.328
Linux Linux kernel>=4.15<4.19.297
Linux Linux kernel>=4.20<5.4.259
Linux Linux kernel>=5.5<5.10.199
Linux Linux kernel>=5.11<5.15.136
Linux Linux kernel>=5.16<6.1.59
Linux Linux kernel>=6.2<6.5.8
Linux Linux kernel=6.6-rc1
Linux Linux kernel=6.6-rc2
Linux Linux kernel=6.6-rc3
Linux Linux kernel=6.6-rc4
Linux Linux kernel=6.6-rc5
IBM Security Verify Governance<=ISVG 10.0.2
IBM Security Verify Governance, Identity Manager Software Stack<=ISVG 10.0.2
IBM Security Verify Governance, Identity Manager Virtual Appliance<=ISVG 10.0.2
IBM Security Verify Governance Identity Manager Container<=ISVG 10.0.2

Event History

Feb 29, 2024
CVE Published
via MITRE·05:43 AM
Data Sourced
via MITRE·05:43 AM
Description
Data Sourced
via Red Hat·11:16 AM
DescriptionSeverityAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2023-52478?

CVE-2023-52478 is classified as a moderate severity vulnerability in the Linux kernel.

2

How do I fix CVE-2023-52478?

To fix CVE-2023-52478, update your Linux kernel to versions 4.14.328, 4.19.297, 5.4.259, 5.10.199, 5.15.136, 6.1.59, 6.5.8, or 6.6 and above.

3

Which versions of the Linux kernel are affected by CVE-2023-52478?

CVE-2023-52478 affects multiple Linux kernel versions prior to 4.14.328, 4.19.297, 5.4.259, 5.10.199, 5.15.136, 6.1.59, 6.5.8, and 6.6.

4

What does CVE-2023-52478 involve?

CVE-2023-52478 involves a potential kernel crash due to time-of-check vs time-of-use (TOCTOU) race conditions in the HID: logitech-hidpp component.

5

Is there a workaround for CVE-2023-52478?

There are no known workarounds for CVE-2023-52478; updating the kernel is the recommended action.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203