{
  "id": "CVE-2025-38349",
  "url": "https://poc.griffinguard.io/cve/CVE-2025-38349",
  "published_at": "2025-07-18T07:53:16.434Z",
  "title": "eventpoll: don't decrement ep refcount while still holding the ep mutex",
  "vendor": "Linux",
  "product": "Linux",
  "cvss": {
    "score": 7.8,
    "source": "cna",
    "vector": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  },
  "kev": {
    "in_kev": false,
    "added_at": null,
    "days_after_publication": null
  },
  "first_poc": null,
  "poc_repo_count": 0,
  "exploit_count": 0,
  "suspicious_repo_count": 0,
  "edge_device": null,
  "description": "In the Linux kernel, the following vulnerability has been resolved:\n\neventpoll: don't decrement ep refcount while still holding the ep mutex\n\nJann Horn points out that epoll is decrementing the ep refcount and then\ndoing a\n\n    mutex_unlock(\u0026ep-\u003emtx);\n\nafterwards. That's very wrong, because it can lead to a use-after-free.\n\nThat pattern is actually fine for the very last reference, because the\ncode in question will delay the actual call to \"ep_free(ep)\" until after\nit has unlocked the mutex.\n\nBut it's wrong for the much subtler \"next to last\" case when somebody\n*else* may also be dropping their reference and free the ep while we're\nstill using the mutex.\n\nNote that this is true even if that other user is also using the same ep\nmutex: mutexes, unlike spinlocks, can not be used for object ownership,\neven if they guarantee mutual exclusion.\n\nA mutex \"unlock\" operation is not atomic, and as one user is still\naccessing the mutex as part of unlocking it, another user can come in\nand get the now released mutex and free the data structure while the\nfirst user is still cleaning up.\n\nSee our mutex documentation in Documentation/locking/mutex-design.rst,\nin particular the section [1] about semantics:\n\n\t\"mutex_unlock() may access the mutex structure even after it has\n\t internally released the lock already - so it's not safe for\n\t another context to acquire the mutex and assume that the\n\t mutex_unlock() context is not using the structure anymore\"\n\nSo if we drop our ep ref before the mutex unlock, but we weren't the\nlast one, we may then unlock the mutex, another user comes in, drops\n_their_ reference and releases the 'ep' as it now has no users - all\nwhile the mutex_unlock() is still accessing it.\n\nFix this by simply moving the ep refcount dropping to outside the mutex:\nthe refcount itself is atomic, and doesn't need mutex protection (that's\nthe whole _point_ of refcounts: unlike mutexes, they are inherently\nabout object lifetimes).",
  "cwe": "CWE-416",
  "cpes": [
    "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
    "cpe:2.3:o:linux:linux_kernel:6.16:rc1:*:*:*:*:*:*",
    "cpe:2.3:o:linux:linux_kernel:6.16:rc2:*:*:*:*:*:*",
    "cpe:2.3:o:linux:linux_kernel:6.16:rc3:*:*:*:*:*:*",
    "cpe:2.3:o:linux:linux_kernel:6.16:rc4:*:*:*:*:*:*",
    "cpe:2.3:o:linux:linux_kernel:6.16:rc5:*:*:*:*:*:*"
  ],
  "cvss_by_source": {
    "cna": 7.8,
    "nvd": 7.8
  },
  "repos": [],
  "remediation": {
    "affected": [
      {
        "vendor": "Linux",
        "product": "Linux",
        "ranges": [
          "\u003e= f2451def095c1743adcfcb0cb5dadc86034e162a, \u003c 263f5de8302a6f2f136d392e5d3f8b1edf922857",
          "\u003e= a1f93804449d13f97dabd4b996817de4bf1ed67a, \u003c b0821ec902d39062356cb644c16e17a705d1c9f5",
          "\u003e= 58c9b016e12855286370dfb704c08498edbc857a, \u003c 521e9ff0b67c66a17d6f9593dfccafaa984aae4c",
          "\u003e= 58c9b016e12855286370dfb704c08498edbc857a, \u003c 6dee745bd0aec9d399df674256e7b1ecdb615444",
          "\u003e= 58c9b016e12855286370dfb704c08498edbc857a, \u003c 605c18698ecfa99165f36b7f59d3ed503e169814",
          "\u003e= 58c9b016e12855286370dfb704c08498edbc857a, \u003c 8c2e52ebbe885c7eeaabd3b7ddcdc1246fc400d2",
          "\u003e= 5.15.209, \u003c 5.15.222",
          "\u003e= 6.1.175, \u003c 6.1.178"
        ],
        "fixed_in": [
          "263f5de8302a6f2f136d392e5d3f8b1edf922857",
          "b0821ec902d39062356cb644c16e17a705d1c9f5",
          "521e9ff0b67c66a17d6f9593dfccafaa984aae4c",
          "6dee745bd0aec9d399df674256e7b1ecdb615444",
          "605c18698ecfa99165f36b7f59d3ed503e169814",
          "8c2e52ebbe885c7eeaabd3b7ddcdc1246fc400d2",
          "5.15.222",
          "6.1.178"
        ]
      },
      {
        "vendor": "Linux",
        "product": "Linux",
        "ranges": [
          "6.4"
        ],
        "fixed_in": [
          "0",
          "5.15.222",
          "6.1.178",
          "6.6.99",
          "6.12.39",
          "6.15.7",
          "6.16"
        ]
      }
    ],
    "upgrade": [
      "Upgrade Linux to 263f5de8302a6f2f136d392e5d3f8b1edf922857 or b0821ec902d39062356cb644c16e17a705d1c9f5 or 521e9ff0b67c66a17d6f9593dfccafaa984aae4c or 6dee745bd0aec9d399df674256e7b1ecdb615444 or 605c18698ecfa99165f36b7f59d3ed503e169814 or 8c2e52ebbe885c7eeaabd3b7ddcdc1246fc400d2 or 5.15.222 or 6.1.178 or later.",
      "Upgrade Linux to 0 or 5.15.222 or 6.1.178 or 6.6.99 or 6.12.39 or 6.15.7 or 6.16 or later."
    ]
  },
  "exploit_refs": [],
  "hunt_profile": [],
  "rules": []
}
