CVE-2025-40315
Description
In the Linux kernel, the following vulnerability has been resolved:
usb: gadget: f_fs: Fix epfile null pointer access after ep enable.
A race condition occurs when ffs_func_eps_enable() runs concurrently with ffs_data_reset(). The ffs_data_clear() called in ffs_data_reset() sets ffs->epfiles to NULL before resetting ffs->eps_count to 0, leading to a NULL pointer dereference when accessing epfile->ep in ffs_func_eps_enable() after successful usb_ep_enable().
The ffs->epfiles pointer is set to NULL in both ffs_data_clear() and ffs_data_close() functions, and its modification is protected by the spinlock ffs->eps_lock. And the whole ffs_func_eps_enable() function is also protected by ffs->eps_lock.
Thus, add NULL pointer handling for ffs->epfiles in the ffs_func_eps_enable() function to fix issues
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Race condition in Linux kernel's f_fs USB gadget driver causes NULL pointer dereference when ffs_func_eps_enable() runs concurrently with ffs_data_reset().
Vulnerability
Overview
A race condition exists in the Linux kernel's USB gadget f_fs (FunctionFS) driver. When ffs_func_eps_enable() executes concurrently with ffs_data_reset(), the function ffs_data_clear() (called by ffs_data_reset()) sets the ffs->epfiles pointer to NULL before resetting ffs->eps_count to 0. This can lead to a NULL pointer dereference when ffs_func_eps_enable() subsequently accesses epfile->ep after a successful usb_ep_enable() call [1][2][3][4].
Attack
Vector and Prerequisites
The vulnerability is triggered by a race condition between two kernel threads or operations: one that enables USB endpoints via ffs_func_eps_enable() and another that resets the FunctionFS data via ffs_data_reset(). An attacker would need to be able to trigger these concurrent perform a USB function enable operation and a functionfs data reset, which typically requires local access to the system or the ability to send specific USB control requests. The race window is narrow but can lead to a crash [1][2][3].
Impact
If the race is won, the kernel will dereference a NULL pointer, resulting in a system crash (kernel oops or panic). This constitutes a denial-of-service (DoS) vulnerability. There is no indication of memory corruption or privilege escalation from this bug [1][2][3][4].
Mitigation
The fix adds a NULL pointer check for ffs->epfiles within ffs_func_eps_enable() after acquiring the ffs->eps_lock spinlock spinlock. This ensures that if epfiles` is NULL (due to a concurrent reset), the function returns an appropriate error code instead of dereferencing the NULL pointer. The patch has been applied to the stable kernel trees as commits [1], [2], [3], and [4] for different kernel versions [1][2][3][4].
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
2Patches
8b00d2572c16e1c0dbd240be39ec40fba7357c53e90563bc1fc1141a530dfd62b808d5c6830880e9df273cfd6f1a7b42fVulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
8- git.kernel.org/stable/c/1c0dbd240be3f87cac321b14e17979b7e9cb6a8fnvd
- git.kernel.org/stable/c/30880e9df27332403dd638a82c27921134b3630bnvd
- git.kernel.org/stable/c/9ec40fba7357df2d36f4c2e2f3b9b1a4fba0a272nvd
- git.kernel.org/stable/c/b00d2572c16e8e59e979960d3383c2ae9cebd195nvd
- git.kernel.org/stable/c/c53e90563bc148e4e0ad09fe130ba2246d426ea6nvd
- git.kernel.org/stable/c/cfd6f1a7b42f62523c96d9703ef32b0dbc495ba4nvd
- git.kernel.org/stable/c/d62b808d5c68a931ad0849a00a5e3be3dd7e0019nvd
- git.kernel.org/stable/c/fc1141a530dfc91f0ee19b7f422a2d24829584bcnvd
News mentions
0No linked articles in our index yet.