CVE-2025-38349: eventpoll: don't decrement ep refcount while still holding the ep mutex

Published Jul 18, 2025
·
Updated

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

eventpoll: don't decrement ep refcount while still holding the ep mutex

Jann Horn points out that epoll is decrementing the ep refcount and then doing a

mutexunlock(&ep->mtx);

afterwards. That's very wrong, because it can lead to a use-after-free.

That pattern is actually fine for the very last reference, because the code in question will delay the actual call to "epfree(ep)" until after it has unlocked the mutex.

But it's wrong for the much subtler "next to last" case when somebody else may also be dropping their reference and free the ep while we're still using the mutex.

Note that this is true even if that other user is also using the same ep mutex: mutexes, unlike spinlocks, can not be used for object ownership, even if they guarantee mutual exclusion.

A mutex "unlock" operation is not atomic, and as one user is still accessing the mutex as part of unlocking it, another user can come in and get the now released mutex and free the data structure while the first user is still cleaning up.

See our mutex documentation in Documentation/locking/mutex-design.rst, in particular the section [1] about semantics:

"mutexunlock() may access the mutex structure even after it has internally released the lock already - so it's not safe for another context to acquire the mutex and assume that the mutexunlock() context is not using the structure anymore"

So if we drop our ep ref before the mutex unlock, but we weren't the last one, we may then unlock the mutex, another user comes in, drops their reference and releases the 'ep' as it now has no users - all while the mutexunlock() is still accessing it.

Fix this by simply moving the ep refcount dropping to outside the mutex: the refcount itself is atomic, and doesn't need mutex protection (that's the whole point of refcounts: unlike mutexes, they are inherently about object lifetimes).

Affected Software

10 affected components
Linux Kernel
Linux Linux kernel>=6.4<6.6.99
Linux Linux kernel>=6.7<6.12.39
Linux Linux kernel>=6.13<6.15.7
Linux Linux kernel=6.16-rc1
Linux Linux kernel=6.16-rc2
Linux Linux kernel=6.16-rc3
Linux Linux kernel=6.16-rc4
Linux Linux kernel=6.16-rc5
Google Android

Event History

Jul 18, 2025
CVE Published
via MITRE·07:53 AM
Data Sourced
via MITRE·07:53 AM
Description
Data Sourced
via Red Hat·08:01 AM
DescriptionSeverityAffected Software
Data Sourced
via NVD·08:15 AM
RemedyDescriptionSeverityWeaknessAffected Software
Dec 1, 2025
Data Sourced
via Android·12:00 AM
SeverityWeaknessAffected Software
Feb 26, 2026
Data Sourced
12:00 AM
SeverityWeakness

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-2025-38349?

CVE-2025-38349 is classified as a moderate severity vulnerability affecting the Linux kernel.

2

How do I fix CVE-2025-38349?

To fix CVE-2025-38349, update your Linux kernel to a version that includes the security patch.

3

Who discovered CVE-2025-38349?

CVE-2025-38349 was discovered by Jann Horn.

4

What systems are affected by CVE-2025-38349?

CVE-2025-38349 affects systems running vulnerable versions of the Linux kernel that use epoll.

5

What type of vulnerability is CVE-2025-38349?

CVE-2025-38349 is a race condition vulnerability related to event polling in the Linux kernel.

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