{"id":"CVE-2025-40285","state":"PUBLISHED","title":"smb/server: fix possible refcount leak in smb2_sess_setup()","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nsmb/server: fix possible refcount leak in smb2_sess_setup()\n\nReference count of ksmbd_session will leak when session need reconnect.\nFix this by adding the missing ksmbd_user_session_put().","publishedAt":"2025-12-06T21:51:09.590Z","updatedAt":"2026-08-05T12:09:15.214Z","severity":{"score":7.5,"label":"High","version":"3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","source":"Linux"},"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"37a0e2b362b3150317fb6e2139de67b1e29ae5ff","status":"affected","lessThan":"6fc935f798d44a8eb8a5e6659198399fbf57b981","versionType":"git"},{"version":"450a844c045ff0895d41b05a1cbe8febd1acfcfd","status":"affected","lessThan":"e671f9bb97805771380c98de944e2ceab6949188","versionType":"git"},{"version":"a39e31e22a535d47b14656a7d6a893c7f6cf758c","status":"affected","lessThan":"dcc51dfe6ff26b52cac106865a172ac982d78401","versionType":"git"},{"version":"b95629435b84b9ecc0c765995204a4d8a913ed52","status":"affected","lessThan":"d37b2c81c83d6c0d5ca582f4fe73c672983f9e0d","versionType":"git"},{"version":"b95629435b84b9ecc0c765995204a4d8a913ed52","status":"affected","lessThan":"379510a815cb2e64eb0a379cb62295d6ade65df0","versionType":"git"},{"version":"2107ab40629aeabbec369cf34b8cf0f288c3eb1b","status":"affected","versionType":"git"},{"version":"6.1.121","status":"affected","lessThan":"6.1.159","versionType":"semver"},{"version":"6.6.67","status":"affected","lessThan":"6.6.117","versionType":"semver"},{"version":"6.12.6","status":"affected","lessThan":"6.12.59","versionType":"semver"},{"version":"5.15.176","status":"affected","lessThan":"5.16","versionType":"semver"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/smb/server/smb2pdu.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.13","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.13","versionType":"semver"},{"version":"6.1.159","status":"unaffected","lessThanOrEqual":"6.1.*","versionType":"semver"},{"version":"6.6.117","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.59","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.17.9","status":"unaffected","lessThanOrEqual":"6.17.*","versionType":"semver"},{"version":"6.18","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/smb/server/smb2pdu.c"]}],"references":["https://git.kernel.org/stable/c/6fc935f798d44a8eb8a5e6659198399fbf57b981","https://git.kernel.org/stable/c/e671f9bb97805771380c98de944e2ceab6949188","https://git.kernel.org/stable/c/dcc51dfe6ff26b52cac106865a172ac982d78401","https://git.kernel.org/stable/c/d37b2c81c83d6c0d5ca582f4fe73c672983f9e0d","https://git.kernel.org/stable/c/379510a815cb2e64eb0a379cb62295d6ade65df0"],"weaknesses":[],"ingestedAt":"2026-10-29T20:09:09.358Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2025/40xxx/CVE-2025-40285.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2025-40285","state":"PUBLISHED","datePublished":"2025-12-06T21:51:09.590Z","dateUpdated":"2026-08-05T12:09:15.214Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2025-04-16T07:20:57.184Z"},"containers":{"cna":{"title":"smb/server: fix possible refcount leak in smb2_sess_setup()","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nsmb/server: fix possible refcount leak in smb2_sess_setup()\n\nReference count of ksmbd_session will leak when session need reconnect.\nFix this by adding the missing ksmbd_user_session_put()."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"37a0e2b362b3150317fb6e2139de67b1e29ae5ff","status":"affected","lessThan":"6fc935f798d44a8eb8a5e6659198399fbf57b981","versionType":"git"},{"version":"450a844c045ff0895d41b05a1cbe8febd1acfcfd","status":"affected","lessThan":"e671f9bb97805771380c98de944e2ceab6949188","versionType":"git"},{"version":"a39e31e22a535d47b14656a7d6a893c7f6cf758c","status":"affected","lessThan":"dcc51dfe6ff26b52cac106865a172ac982d78401","versionType":"git"},{"version":"b95629435b84b9ecc0c765995204a4d8a913ed52","status":"affected","lessThan":"d37b2c81c83d6c0d5ca582f4fe73c672983f9e0d","versionType":"git"},{"version":"b95629435b84b9ecc0c765995204a4d8a913ed52","status":"affected","lessThan":"379510a815cb2e64eb0a379cb62295d6ade65df0","versionType":"git"},{"version":"2107ab40629aeabbec369cf34b8cf0f288c3eb1b","status":"affected","versionType":"git"},{"version":"6.1.121","status":"affected","lessThan":"6.1.159","versionType":"semver"},{"version":"6.6.67","status":"affected","lessThan":"6.6.117","versionType":"semver"},{"version":"6.12.6","status":"affected","lessThan":"6.12.59","versionType":"semver"},{"version":"5.15.176","status":"affected","lessThan":"5.16","versionType":"semver"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/smb/server/smb2pdu.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.13","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.13","versionType":"semver"},{"version":"6.1.159","status":"unaffected","lessThanOrEqual":"6.1.*","versionType":"semver"},{"version":"6.6.117","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.59","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.17.9","status":"unaffected","lessThanOrEqual":"6.17.*","versionType":"semver"},{"version":"6.18","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/smb/server/smb2pdu.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/6fc935f798d44a8eb8a5e6659198399fbf57b981"},{"url":"https://git.kernel.org/stable/c/e671f9bb97805771380c98de944e2ceab6949188"},{"url":"https://git.kernel.org/stable/c/dcc51dfe6ff26b52cac106865a172ac982d78401"},{"url":"https://git.kernel.org/stable/c/d37b2c81c83d6c0d5ca582f4fe73c672983f9e0d"},{"url":"https://git.kernel.org/stable/c/379510a815cb2e64eb0a379cb62295d6ade65df0"}],"metrics":[{"cvssV3_1":{"version":"3.1","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","baseScore":7.5,"baseSeverity":"HIGH"},"scenarios":[{"lang":"en","value":"AV:N - ksmbd is the in-kernel SMB server on TCP/445, and the leak is driven entirely by remote SMB2 SESSION_SETUP and LOGOFF PDUs on the attacker's own TCP connections. No local access to the target is required.\nAC:L - The attacker controls both sides of the race — it pipelines the SESSION_SETUP requests that take the reference and issues the LOGOFF/PreviousSessionId request that flips conn->status to NEED_RECONNECT — and the window is wide because ksmbd_conn_wait_idle()/ksmbd_conn_wait_idle_sess_id() hold that status for the duration of the teardown (up to 120 s). Failed attempts are harmless and can be retried indefinitely.\nPR:N - smb2_check_user_session() explicitly bypasses session validation for SMB2_SESSION_SETUP, and the session is registered in conn->sessions before any credential check, so the leaking lookup is reached with zero credentials. On the common guest-mapped ksmbd share, ntlm_authenticate() skips password verification for user_guest(), so the LOGOFF that flips the connection to NEED_RECONNECT is also available unauthenticated.\nUI:N - The attacker opens its own connections and issues every request itself; no legitimate user or administrator action is involved.\nS:U - The leaked session object and its pinned file references are kernel resources within the same security authority as the ksmbd server; no VM, IOMMU, or sandbox boundary is crossed.\nC:N - Nothing is read out of bounds and nothing is transmitted back to the client on this error path — the only effect is that a reference count is never decremented, so no kernel data is disclosed.\nI:N - No memory is written out of bounds or freed early; the object simply outlives its intended lifetime, so no kernel data or control flow is modified.\nA:H - Each won race permanently leaks a struct ksmbd_session plus its entire file table, so open struct file/inode/dentry references are pinned forever (also blocking unmount), and the attack is replayable without limit over surviving connections, driving unbounded kernel memory and handle exhaustion to OOM and system hang."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-08-05T12:09:15.214Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.1.121","versionEndExcluding":"6.1.159"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.6.67","versionEndExcluding":"6.6.117"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.12.6","versionEndExcluding":"6.12.59"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.13","versionEndExcluding":"6.17.9"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.13","versionEndExcluding":"6.18"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.15.176"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}