VYPR
Unrated severityNVD Advisory· Published Dec 16, 2025· Updated Apr 15, 2026

CVE-2025-68282

CVE-2025-68282

Description

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

usb: gadget: udc: fix use-after-free in usb_gadget_state_work

A race condition during gadget teardown can lead to a use-after-free in usb_gadget_state_work(), as reported by KASAN:

BUG: KASAN: invalid-access in sysfs_notify+0x2c/0xd0 Workqueue: events usb_gadget_state_work

The fundamental race occurs because a concurrent event (e.g., an interrupt) can call usb_gadget_set_state() and schedule gadget->work at any time during the cleanup process in usb_del_gadget().

Commit 399a45e5237c ("usb: gadget: core: flush gadget workqueue after device removal") attempted to fix this by moving flush_work() to after device_del(). However, this does not fully solve the race, as a new work item can still be scheduled *after* flush_work() completes but before the gadget's memory is freed, leading to the same use-after-free.

This patch fixes the race condition robustly by introducing a 'teardown' flag and a 'state_lock' spinlock to the usb_gadget struct. The flag is set during cleanup in usb_del_gadget() *before* calling flush_work() to prevent any new work from being scheduled once cleanup has commenced. The scheduling site, usb_gadget_set_state(), now checks this flag under the lock before queueing the work, thus safely closing the race window.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

A use-after-free in the Linux kernel's USB gadget subsystem due to a race condition during gadget teardown, fixed by adding a teardown flag and state_lock.

Vulnerability

CVE-2025-68282: Use-After-Free in Linux Kernel USB Gadget

A race condition in the Linux kernel's USB gadget subsystem can lead to a use-after-free vulnerability in the usb_gadget_state_work() function. The root cause is that during gadget teardown in usb_del_gadget(), a concurrent event (e.g., an interrupt) can call usb_gadget_set_state() and schedule the gadget's workqueue after the cleanup has begun but before the gadget's memory is freed. This results in the workqueue accessing freed memory, as reported by KASAN with an invalid access in sysfs_notify [1].

##Exploitation

The vulnerability is triggered during the gadget removal process. A previous fix (commit 399a45e5237c) moved flush_work() to after device_del(), but this did not fully close the race because a new work item could be scheduled after flush_work() completes but before memory is freed. The attack surface is local, requiring the ability to trigger gadget teardown while a concurrent event (e.g., an interrupt) schedules state work. No special privileges are needed beyond access to the USB gadget subsystem [1].

##Impact An attacker who can trigger this race condition can cause a use-after-free, potentially leading to memory corruption, system crash (denial of service), or possibly privilege escalation if the freed memory is reallocated for a different purpose. The vulnerability is rated with a CVSS score that reflects the potential for high impact on availability and integrity [1].

##Mitigation The fix introduces a 'teardown' flag and a 'state_lock' spinlock to the usb_gadget struct. The flag is set during cleanup in usb_del_gadget() before calling flush_work(), and usb_gadget_set_state() checks this flag under the lock before queueing work. This robustly prevents new work from being scheduled once teardown has started. The patch has been applied to the stable kernel tree [1][2][3]. Users should update to a kernel version containing this fix.

AI Insight generated on May 19, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected products

1

Patches

0

No patches discovered yet.

Vulnerability mechanics

AI mechanics synthesis has not run for this CVE yet.

References

7

News mentions

0

No linked articles in our index yet.