eventpoll: don't decrement ep refcount while still holding the ep mutex
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 58c9b016e12855286370dfb704c08498edbc857a · < 8c2e52ebbe885c7eeaabd3b7ddcdc1246fc400d2| No fix yet |
| Linux Linux |
|
|
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.
From the CVE record · Linux
The Linux kernel's eventpoll code can decrement an epoll reference count while still holding its mutex. If another user drops the remaining reference and frees the object during mutex unlock, a use-after-free can occur. The input does not specify whether exploitation requires local or network access, authentication, or user interaction.
Engineers running Linux kernels should check whether their kernel includes the eventpoll fix; affected versions are not specified.