# CVE-2026-31477: ksmbd: fix memory leaks and NULL deref in smb2\_lock()

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.5
- **CVSS:** 7.5 (v3.1, CNA) `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Network; Attack complexity: Low; Privileges required: None; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Remote, no login needed
- **EPSS:** 0.71% (percentile 49, 2026-11-26)
- **CWE:** CWE-476
- **Published:** 2026-04-22T13:54:05.470Z
- **Modified:** 2026-11-11T23:10:00.263Z

## Who should check

- Anyone running Linux \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< cdac6f7e7e428dc70e3b5898ac6999a72ed13993; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< c9b95ef6f5039f19e46c3a521a4fe1752d91dfe9; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< 91aeaa7256006d79a37298f5a1df23325db91599; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< 3cdacd11b41569ce75b3162142240f2355e04900; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< aab42f0795620cf0d3955a520f571f697d0f9a2a; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< 309b44ed684496ed3f9c5715d10b899338623512
- Anyone running Linux 5.15

## Description

In the Linux kernel, the following vulnerability has been resolved:

ksmbd: fix memory leaks and NULL deref in smb2\_lock()

smb2\_lock() has three error handling issues after list\_del() detaches
smb\_lock from lock\_list at no\_check\_cl:

1) If vfs\_lock\_file() returns an unexpected error in the non-UNLOCK
   path, goto out leaks smb\_lock and its flock because the out:
   handler only iterates lock\_list and rollback\_list, neither of
   which contains the detached smb\_lock.

2) If vfs\_lock\_file() returns -ENOENT in the UNLOCK path, goto out
   leaks smb\_lock and flock for the same reason.  The error code
   returned to the dispatcher is also stale.

3) In the rollback path, smb\_flock\_init() can return NULL on
   allocation failure.  The result is dereferenced unconditionally,
   causing a kernel NULL pointer dereference.  Add a NULL check to
   prevent the crash and clean up the bookkeeping; the VFS lock
   itself cannot be rolled back without the allocation and will be
   released at file or connection teardown.

Fix cases 1 and 2 by hoisting the locks\_free\_lock()/kfree() to before
the if(!rc) check in the UNLOCK branch so all exit paths share one
free site, and by freeing smb\_lock and flock before goto out in the
non-UNLOCK branch.  Propagate the correct error code in both cases.
Fix case 3 by wrapping the VFS unlock in an if(rlock) guard and adding
a NULL check for locks\_free\_lock(rlock) in the shared cleanup.

Found via call-graph analysis using sqry.

## Affected and fixed versions

- Linux: \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< cdac6f7e7e428dc70e3b5898ac6999a72ed13993; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< c9b95ef6f5039f19e46c3a521a4fe1752d91dfe9; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< 91aeaa7256006d79a37298f5a1df23325db91599; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< 3cdacd11b41569ce75b3162142240f2355e04900; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< aab42f0795620cf0d3955a520f571f697d0f9a2a; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< 309b44ed684496ed3f9c5715d10b899338623512 (cvelist)
- Linux: 5.15 (cvelist)

## Mitigation

- Upgrade Linux to 309b44ed684496ed3f9c5715d10b899338623512 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2026-31477. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2026-31477.md
Affected: Linux >= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, < cdac6f7e7e428dc70e3b5898ac6999a72ed13993; >= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, < c9b95ef6f5039f19e46c3a521a4fe1752d91dfe9; >= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, < 91aeaa7256006d79a37298f5a1df23325db91599; >= e2f34481b24db2fd634b5ed…
Fixed in: Linux 91aeaa7256006d79a37298f5a1df23325db91599, Linux 3cdacd11b41569ce75b3162142240f2355e04900, Linux 309b44ed684496ed3f9c5715d10b899338623512

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2026-31477 being exploited?

There is no confirmed exploitation: CVE-2026-31477 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.71% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2026-31477?

High: CVSS 7.5 (v3.1, scored by CNA). Remote, no login needed.

### Which versions are affected by CVE-2026-31477?

Linux \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< cdac6f7e7e428dc70e3b5898ac6999a72ed13993; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< c9b95ef6f5039f19e46c3a521a4fe1752d91dfe9; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< 91aeaa7256006d79a37298f5a1df23325db91599; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< 3cdacd11b41569ce75b3162142240f2355e04900; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< aab42f0795620cf0d3955a520f571f697d0f9a2a; \>= e2f34481b24db2fd634b5edb0a5bd0e4d38cc6e9, \< 309b44ed684496ed3f9c5715d10b899338623512; Linux 5.15.

### Is there a fix for CVE-2026-31477?

Yes. Fixed in Linux 91aeaa7256006d79a37298f5a1df23325db91599, Linux 3cdacd11b41569ce75b3162142240f2355e04900, Linux 309b44ed684496ed3f9c5715d10b899338623512. Upgrade Linux to 309b44ed684496ed3f9c5715d10b899338623512 or later.

### How do I check if I'm affected by CVE-2026-31477?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/cdac6f7e7e428dc70e3b5898ac6999a72ed13993>
- patch: <https://git.kernel.org/stable/c/c9b95ef6f5039f19e46c3a521a4fe1752d91dfe9>
- patch: <https://git.kernel.org/stable/c/91aeaa7256006d79a37298f5a1df23325db91599>
- patch: <https://git.kernel.org/stable/c/3cdacd11b41569ce75b3162142240f2355e04900>
- patch: <https://git.kernel.org/stable/c/aab42f0795620cf0d3955a520f571f697d0f9a2a>
- patch: <https://git.kernel.org/stable/c/309b44ed684496ed3f9c5715d10b899338623512>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2026-31477>

HTML: <https://flawdb.com/CVE-2026-31477> · JSON: <https://flawdb.com/api/v1/entries/CVE-2026-31477>
