Skip to content

In the Linux kernel, the following vulnerability has been...

Moderate severity Unreviewed Published Dec 28, 2024 to the GitHub Advisory Database • Updated Jan 31, 2025

Package

No package listedSuggest a package

Affected versions

Unknown

Patched versions

Unknown

Description

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

usb: musb: Fix hardware lockup on first Rx endpoint request

There is a possibility that a request's callback could be invoked from
usb_ep_queue() (call trace below, supplemented with missing calls):

req->complete from usb_gadget_giveback_request
(drivers/usb/gadget/udc/core.c:999)
usb_gadget_giveback_request from musb_g_giveback
(drivers/usb/musb/musb_gadget.c:147)
musb_g_giveback from rxstate
(drivers/usb/musb/musb_gadget.c:784)
rxstate from musb_ep_restart
(drivers/usb/musb/musb_gadget.c:1169)
musb_ep_restart from musb_ep_restart_resume_work
(drivers/usb/musb/musb_gadget.c:1176)
musb_ep_restart_resume_work from musb_queue_resume_work
(drivers/usb/musb/musb_core.c:2279)
musb_queue_resume_work from musb_gadget_queue
(drivers/usb/musb/musb_gadget.c:1241)
musb_gadget_queue from usb_ep_queue
(drivers/usb/gadget/udc/core.c:300)

According to the docstring of usb_ep_queue(), this should not happen:

"Note that @Req's ->complete() callback must never be called from within
usb_ep_queue() as that can create deadlock situations."

In fact, a hardware lockup might occur in the following sequence:

  1. The gadget is initialized using musb_gadget_enable().
  2. Meanwhile, a packet arrives, and the RXPKTRDY flag is set, raising an
    interrupt.
  3. If IRQs are enabled, the interrupt is handled, but musb_g_rx() finds an
    empty queue (next_request() returns NULL). The interrupt flag has
    already been cleared by the glue layer handler, but the RXPKTRDY flag
    remains set.
  4. The first request is enqueued using usb_ep_queue(), leading to the call
    of req->complete(), as shown in the call trace above.
  5. If the callback enables IRQs and another packet is waiting, step (3)
    repeats. The request queue is empty because usb_g_giveback() removes the
    request before invoking the callback.
  6. The endpoint remains locked up, as the interrupt triggered by hardware
    setting the RXPKTRDY flag has been handled, but the flag itself remains
    set.

For this scenario to occur, it is only necessary for IRQs to be enabled at
some point during the complete callback. This happens with the USB Ethernet
gadget, whose rx_complete() callback calls netif_rx(). If called in the
task context, netif_rx() disables the bottom halves (BHs). When the BHs are
re-enabled, IRQs are also enabled to allow soft IRQs to be processed. The
gadget itself is initialized at module load (or at boot if built-in), but
the first request is enqueued when the network interface is brought up,
triggering rx_complete() in the task context via ioctl(). If a packet
arrives while the interface is down, it can prevent the interface from
receiving any further packets from the USB host.

The situation is quite complicated with many parties involved. This
particular issue can be resolved in several possible ways:

  1. Ensure that callbacks never enable IRQs. This would be difficult to
    enforce, as discovering how netif_rx() interacts with interrupts was
    already quite challenging and u_ether is not the only function driver.
    Similar "bugs" could be hidden in other drivers as well.
  2. Disable MUSB interrupts in musb_g_giveback() before calling the callback
    and re-enable them afterwars (by calling musb_{dis,en}able_interrupts(),
    for example). This would ensure that MUSB interrupts are not handled
    during the callback, even if IRQs are enabled. In fact, it would allow
    IRQs to be enabled when releasing the lock. However, this feels like an
    inelegant hack.
  3. Modify the interrupt handler to clear the RXPKTRDY flag if the request
    queue is empty. While this approach also feels like a hack, it wastes
    CPU time by attempting to handle incoming packets when the software is
    not ready to process them.
  4. Flush the Rx FIFO instead of calling rxstate() in musb_ep_restart().
    This ensures that the hardware can receive packets when there is at
    least one request in the queue. Once I
    ---truncated---

References

Published by the National Vulnerability Database Dec 28, 2024
Published to the GitHub Advisory Database Dec 28, 2024
Last updated Jan 31, 2025

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(5th percentile)

Weaknesses

CVE ID

CVE-2024-56687

GHSA ID

GHSA-x3r6-6fxj-5f4r

Source code

No known source code

Dependabot alerts are not supported on this advisory because it does not have a package from a supported ecosystem with an affected and fixed version.

Learn more about GitHub language support

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.