{"id":66510,"date":"2025-07-18T12:32:02","date_gmt":"2025-07-18T09:02:02","guid":{"rendered":"https:\/\/afaghhosting.net\/blog\/cve-2025-38349-linux-kernel-epoll-use-after-free-vulnerability\/"},"modified":"2025-07-18T12:32:02","modified_gmt":"2025-07-18T09:02:02","slug":"cve-2025-38349-linux-kernel-epoll-use-after-free-vulnerability","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/cve-2025-38349-linux-kernel-epoll-use-after-free-vulnerability\/","title":{"rendered":"CVE-2025-38349 &#8211; Linux Kernel Epoll Use-After-Free Vulnerability"},"content":{"rendered":"<p><strong>CVE ID : <\/strong>CVE-2025-38349<br \/>\n<br \/>\n<strong>Published : <\/strong> 18. Juli 2025 08:15 | 28\u00a0Minuten ago<br \/>\n<br \/>\n<strong>Description : <\/strong>In the Linux kernel, the following vulnerability has been resolved:<\/p>\n<p>eventpoll: don&#8217;t decrement ep refcount while still holding the ep mutex<\/p>\n<p>Jann Horn points out that epoll is decrementing the ep refcount and then<br \/>\ndoing a<\/p>\n<p>    mutex_unlock(&amp;ep-&gt;mtx);<\/p>\n<p>afterwards. That&#8217;s very wrong, because it can lead to a use-after-free.<\/p>\n<p>That pattern is actually fine for the very last reference, because the<br \/>\ncode in question will delay the actual call to &#8220;ep_free(ep)&#8221; until after<br \/>\nit has unlocked the mutex.<\/p>\n<p>But it&#8217;s wrong for the much subtler &#8220;next to last&#8221; case when somebody<br \/>\n*else* may also be dropping their reference and free the ep while we&#8217;re<br \/>\nstill using the mutex.<\/p>\n<p>Note that this is true even if that other user is also using the same ep<br \/>\nmutex: mutexes, unlike spinlocks, can not be used for object ownership,<br \/>\neven if they guarantee mutual exclusion.<\/p>\n<p>A mutex &#8220;unlock&#8221; operation is not atomic, and as one user is still<br \/>\naccessing the mutex as part of unlocking it, another user can come in<br \/>\nand get the now released mutex and free the data structure while the<br \/>\nfirst user is still cleaning up.<\/p>\n<p>See our mutex documentation in Documentation\/locking\/mutex-design.rst,<br \/>\nin particular the section [1] about semantics:<\/p>\n<p>\t&#8220;mutex_unlock() may access the mutex structure even after it has<br \/>\n\t internally released the lock already &#8211; so it&#8217;s not safe for<br \/>\n\t another context to acquire the mutex and assume that the<br \/>\n\t mutex_unlock() context is not using the structure anymore&#8221;<\/p>\n<p>So if we drop our ep ref before the mutex unlock, but we weren&#8217;t the<br \/>\nlast one, we may then unlock the mutex, another user comes in, drops<br \/>\n_their_ reference and releases the &#8216;ep&#8217; as it now has no users &#8211; all<br \/>\nwhile the mutex_unlock() is still accessing it.<\/p>\n<p>Fix this by simply moving the ep refcount dropping to outside the mutex:<br \/>\nthe refcount itself is atomic, and doesn&#8217;t need mutex protection (that&#8217;s<br \/>\nthe whole _point_ of refcounts: unlike mutexes, they are inherently<br \/>\nabout object lifetimes).<br \/>\n<br \/>\n<strong>Severity:<\/strong> 0.0 | NA<br \/>\n<br \/>\nVisit the link for more details, such as CVSS details, affected products, timeline, and more&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CVE ID : CVE-2025-38349 Published : 18. Juli 2025 08:15 | 28\u00a0Minuten ago Description : In the Linux kernel, the following vulnerability has been resolved: eventpoll: don&#8217;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(&amp;ep-&gt;mtx); afterwards. That&#8217;s very &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-66510","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/66510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=66510"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/66510\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=66510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=66510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=66510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}