eventpoll: don't decrement ep refcount while still holding the ep mutex
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 mutex_unlock(&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 "ep_free(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: "mutex_unlock() 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 mutex_unlock() context is not using the structure anymore" So if we drop our ep ref before the mutex unlock, but we weren'
CVE-2025-38349
Primary source · Revision 1
Imported from structured advisory data. Source references identify upstream records or fields; verify affected versions and your deployed configuration.
Security context
Source reference: cve:CVE-2025-38349
Linux
Source reference: /containers/cna/affected/0/product
- Affected versions
- Not stated in this record
- Fixed versions
- Not stated in this record
- Prerequisites
- Not stated in this record
Linux
Source reference: /containers/cna/affected/1/product
- Affected versions
- Not stated in this record
- Fixed versions
- Not stated in this record
- Prerequisites
- Not stated in this record
Structured affected-version data
Original package identities and version rules from this source.
[
{
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"vendor": "Linux",
"product": "Linux",
"versions": [
{
"status": "affected",
"version": "f2451def095c1743adcfcb0cb5dadc86034e162a",
"lessThan": "263f5de8302a6f2f136d392e5d3f8b1edf922857",
"versionType": "git"
},
{
"status": "affected",
"version": "a1f93804449d13f97dabd4b996817de4bf1ed67a",
"lessThan": "b0821ec902d39062356cb644c16e17a705d1c9f5",
"versionType": "git"
},
{
"status": "affected",
"version": "58c9b016e12855286370dfb704c08498edbc857a",
"lessThan": "521e9ff0b67c66a17d6f9593dfccafaa984aae4c",
"versionType": "git"
},
{
"status": "affected",
"version": "58c9b016e12855286370dfb704c08498edbc857a",
"lessThan": "6dee745bd0aec9d399df674256e7b1ecdb615444",
"versionType": "git"
},
{
"status": "affected",
"version": "58c9b016e12855286370dfb704c08498edbc857a",
"lessThan": "605c18698ecfa99165f36b7f59d3ed503e169814",
"versionType": "git"
},
{
"status": "affected",
"version": "58c9b016e12855286370dfb704c08498edbc857a",
"lessThan": "8c2e52ebbe885c7eeaabd3b7ddcdc1246fc400d2",
"versionType": "git"
},
{
"status": "affected",
"version": "5.15.209",
"lessThan": "5.15.222",
"versionType": "semver"
},
{
"status": "affected",
"version": "6.1.175",
"lessThan": "6.1.178",
"versionType": "semver"
}
],
"programFiles": [
"fs/eventpoll.c"
],
"defaultStatus": "unaffected"
},
{
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"vendor": "Linux",
"product": "Linux",
"versions": [
{
"status": "affected",
"version": "6.4"
},
{
"status": "unaffected",
"version": "0",
"lessThan": "6.4",
"versionType": "semver"
},
{
"status": "unaffected",
"version": "5.15.222",
"versionType": "semver",
"lessThanOrEqual": "5.15.*"
},
{
"status": "unaffected",
"version": "6.1.178",
"versionType": "semver",
"lessThanOrEqual": "6.1.*"
},
{
"status": "unaffected",
"version": "6.6.99",
"versionType": "semver",
"lessThanOrEqual": "6.6.*"
},
{
"status": "unaffected",
"version": "6.12.39",
"versionType": "semver",
"lessThanOrEqual": "6.12.*"
},
{
"status": "unaffected",
"version": "6.15.7",
"versionType": "semver",
"lessThanOrEqual": "6.15.*"
},
{
"status": "unaffected",
"version": "6.16",
"versionType": "original_commit_for_fix",
"lessThanOrEqual": "*"
}
],
"programFiles": [
"fs/eventpoll.c"
],
"defaultStatus": "affected"
}
]- Related CVEs
- CVE-2025-38349
Source reference:
/cveMetadata/cveId
Publisher severity
high
Source reference: /containers/cna/metrics
- Event
- #8239 · Revision 1
- Added to Heist Feed
- Publisher date