{
  "schema_version": "1.6.1",
  "id": "RPI-CVE-2025-22074",
  "modified": "2026-10-09T11:39:44Z",
  "upstream": [
    "CVE-2025-22074"
  ],
  "published": "2025-04-16T14:14:59Z",
  "summary": "ksmbd: fix r_count dec/increment mismatch",
  "details": "In the Linux kernel, the following vulnerability has been resolved:\n\nksmbd: fix r_count dec/increment mismatch\n\nr_count is only increased when there is an oplock break wait,\nso r_count inc/decrement are not paired. This can cause r_count\nto become negative, which can lead to a problem where the ksmbd\nthread does not terminate.",
  "severity": [
    {
      "type": "CVSS_V3",
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
    }
  ],
  "affected": [
    {
      "package": {
        "ecosystem": "Raspberry Pi OS:12",
        "name": "linux"
      },
      "versions": [
        "1:6.12.20-1+rpt1~bpo12+1"
      ],
      "ecosystem_specific": {
        "binaries": [
          {
            "binary_name": "linux-image-6.12.20+rpt-rpi-2712",
            "binary_version": "1:6.12.20-1+rpt1~bpo12+1"
          },
          {
            "binary_name": "linux-image-6.12.20+rpt-rpi-v6",
            "binary_version": "1:6.12.20-1+rpt1~bpo12+1"
          },
          {
            "binary_name": "linux-image-6.12.20+rpt-rpi-v7",
            "binary_version": "1:6.12.20-1+rpt1~bpo12+1"
          },
          {
            "binary_name": "linux-image-6.12.20+rpt-rpi-v7l",
            "binary_version": "1:6.12.20-1+rpt1~bpo12+1"
          },
          {
            "binary_name": "linux-image-6.12.20+rpt-rpi-v8",
            "binary_version": "1:6.12.20-1+rpt1~bpo12+1"
          }
        ]
      },
      "database_specific": {
        "per_version": {
          "1:6.12.20-1+rpt1~bpo12+1": {
            "linux_commit": "cd231d4775b14f228606c09f219b48308f6ab3aa",
            "upstream_version": "6.12.20",
            "assessment": "commit ancestry (strak rule)",
            "upstream_fixed": "6.12.23"
          }
        }
      }
    },
    {
      "package": {
        "ecosystem": "Raspberry Pi OS:13",
        "name": "linux"
      },
      "versions": [
        "1:6.12.20-1+rpt1"
      ],
      "ecosystem_specific": {
        "binaries": [
          {
            "binary_name": "linux-image-6.12.20+rpt-rpi-2712",
            "binary_version": "1:6.12.20-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.12.20+rpt-rpi-v6",
            "binary_version": "1:6.12.20-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.12.20+rpt-rpi-v7",
            "binary_version": "1:6.12.20-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.12.20+rpt-rpi-v7l",
            "binary_version": "1:6.12.20-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.12.20+rpt-rpi-v8",
            "binary_version": "1:6.12.20-1+rpt1"
          }
        ]
      },
      "database_specific": {
        "per_version": {
          "1:6.12.20-1+rpt1": {
            "linux_commit": "cd231d4775b14f228606c09f219b48308f6ab3aa",
            "upstream_version": "6.12.20",
            "assessment": "commit ancestry (strak rule)",
            "upstream_fixed": "6.12.23"
          }
        }
      }
    }
  ],
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://www.cve.org/CVERecord?id=CVE-2025-22074"
    },
    {
      "type": "FIX",
      "url": "https://git.kernel.org/stable/c/4790bcb269e5d6d88200a67c54ae6d627332a3be"
    },
    {
      "type": "FIX",
      "url": "https://git.kernel.org/stable/c/457db486203c90e10c3efc87fd45cc7000b1cd36"
    },
    {
      "type": "FIX",
      "url": "https://git.kernel.org/stable/c/20378cf48359f39dee0ef9b61470ebe77bd49c0d"
    },
    {
      "type": "FIX",
      "url": "https://git.kernel.org/stable/c/c2ec33d46b4d1c8085dab5d02e00b21f4f0fb8a9"
    },
    {
      "type": "FIX",
      "url": "https://git.kernel.org/stable/c/ddb7ea36ba7129c2ed107e2186591128618864e1"
    }
  ],
  "database_specific": {
    "source": "https://git.kernel.org/pub/scm/linux/security/vulns.git",
    "upstream_modified": "2026-08-05T12:19:11Z",
    "severity": {
      "source": "kernel CNA",
      "cvss_v3_score": 8.8,
      "cvss_v3_severity": "High",
      "scenario": "AV:N - ksmbd is the in-kernel SMB server listening on TCP/445; the oplock/lease break path is driven entirely by SMB2 CREATE/WRITE/SET_INFO requests sent by a remote peer over the network.\nAC:L - The attacker owns both connections involved (the oplock holder and the breaker) and controls exactly how many unbalanced decrements occur by sending N writes, so `r_count` can be steered to zero or negative deterministically; no condition outside the attacker's control is needed.\nPR:L - Obtaining a level-II oplock or read-caching lease requires an open file handle, which requires a completed SMB2 session setup and tree connect with valid credentials \u2014 a low-privileged authenticated share user suffices.\nUI:N - The attacker triggers the oplock break itself by writing to or truncating the file from a second connection; no action by any local user or administrator is required.\nS:U - The corruption and its consequences (hung ksmbd kthread, freed ksmbd_conn/transport reuse) remain entirely within the kernel's own security authority.\nC:H - The underflow lets the connection teardown free `ksmbd_conn`, the transport and the socket while an in-flight work item still dereferences them, and the attacker can reoccupy that slab with request-buffer data, yielding a use-after-free read primitive over kernel memory including session keys and credentials.\nI:H - The same use-after-free gives writes through the stale `work->conn`/`work->sess` pointers and via `ksmbd_conn_write()` into freed and reallocated memory, which is the standard basis for heap-spray-driven control-flow hijacking.\nA:H - A negative `r_count` makes `wait_event(conn->r_count_q, r_count == 0)` unsatisfiable, hanging the `ksmbd:%u` kthread uninterruptibly and permanently leaking the socket, connection and sessions; this is repeatable per connection until resources are exhausted, and the UAF variant additionally causes kernel oopses."
    }
  }
}
