# CVE-2025-40274: KVM: guest\_memfd: Remove bindings on memslot deletion when gmem is dying

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

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.22% (percentile 8, 2026-11-26)
- **Published:** 2025-12-06T21:50:56.832Z
- **Modified:** 2026-08-05T12:09:07.765Z

## Who should check

- Anyone running Linux \>= a7800aa80ea4d5356b8474c2302812e9d4926fa6, \< a8ac2bd0f98e1a230f1eb3260fa552bf2ef1753b; \>= a7800aa80ea4d5356b8474c2302812e9d4926fa6, \< 393893693a523e053f84d69320d090b93503f79f; \>= a7800aa80ea4d5356b8474c2302812e9d4926fa6, \< ae431059e75d36170a5ae6b44cc4d06d43613215
- Anyone running Linux 6.8

## Description

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

KVM: guest\_memfd: Remove bindings on memslot deletion when gmem is dying

When unbinding a memslot from a guest\_memfd instance, remove the bindings
even if the guest\_memfd file is dying, i.e. even if its file refcount has
gone to zero.  If the memslot is freed before the file is fully released,
nullifying the memslot side of the binding in kvm\_gmem\_release() will
write to freed memory, as detected by syzbot+KASAN:

  ==================================================================
  BUG: KASAN: slab-use-after-free in kvm\_gmem\_release+0x176/0x440 virt/kvm/guest\_memfd.c:353
  Write of size 8 at addr ffff88807befa508 by task syz.0.17/6022

  CPU: 0 UID: 0 PID: 6022 Comm: syz.0.17 Not tainted syzkaller \#0 PREEMPT(full)
  Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/02/2025
  Call Trace:
   \<TASK\>
   dump\_stack\_lvl+0x189/0x250 lib/dump\_stack.c:120
   print\_address\_description mm/kasan/report.c:378 \[inline\]
   print\_report+0xca/0x240 mm/kasan/report.c:482
   kasan\_report+0x118/0x150 mm/kasan/report.c:595
   kvm\_gmem\_release+0x176/0x440 virt/kvm/guest\_memfd.c:353
   \_\_fput+0x44c/0xa70 fs/file\_table.c:468
   task\_work\_run+0x1d4/0x260 kernel/task\_work.c:227
   resume\_user\_mode\_work include/linux/resume\_user\_mode.h:50 \[inline\]
   exit\_to\_user\_mode\_loop+0xe9/0x130 kernel/entry/common.c:43
   exit\_to\_user\_mode\_prepare include/linux/irq-entry-common.h:225 \[inline\]
   syscall\_exit\_to\_user\_mode\_work include/linux/entry-common.h:175 \[inline\]
   syscall\_exit\_to\_user\_mode include/linux/entry-common.h:210 \[inline\]
   do\_syscall\_64+0x2bd/0xfa0 arch/x86/entry/syscall\_64.c:100
   entry\_SYSCALL\_64\_after\_hwframe+0x77/0x7f
  RIP: 0033:0x7fbeeff8efc9
   \</TASK\>

  Allocated by task 6023:
   kasan\_save\_stack mm/kasan/common.c:56 \[inline\]
   kasan\_save\_track+0x3e/0x80 mm/kasan/common.c:77
   poison\_kmalloc\_redzone mm/kasan/common.c:397 \[inline\]
   \_\_kasan\_kmalloc+0x93/0xb0 mm/kasan/common.c:414
   kasan\_kmalloc include/linux/kasan.h:262 \[inline\]
   \_\_kmalloc\_cache\_noprof+0x3e2/0x700 mm/slub.c:5758
   kmalloc\_noprof include/linux/slab.h:957 \[inline\]
   kzalloc\_noprof include/linux/slab.h:1094 \[inline\]
   kvm\_set\_memory\_region+0x747/0xb90 virt/kvm/kvm\_main.c:2104
   kvm\_vm\_ioctl\_set\_memory\_region+0x6f/0xd0 virt/kvm/kvm\_main.c:2154
   kvm\_vm\_ioctl+0x957/0xc60 virt/kvm/kvm\_main.c:5201
   vfs\_ioctl fs/ioctl.c:51 \[inline\]
   \_\_do\_sys\_ioctl fs/ioctl.c:597 \[inline\]
   \_\_se\_sys\_ioctl+0xfc/0x170 fs/ioctl.c:583
   do\_syscall\_x64 arch/x86/entry/syscall\_64.c:63 \[inline\]
   do\_syscall\_64+0xfa/0xfa0 arch/x86/entry/syscall\_64.c:94
   entry\_SYSCALL\_64\_after\_hwframe+0x77/0x7f

  Freed by task 6023:
   kasan\_save\_stack mm/kasan/common.c:56 \[inline\]
   kasan\_save\_track+0x3e/0x80 mm/kasan/common.c:77
   kasan\_save\_free\_info+0x46/0x50 mm/kasan/generic.c:584
   poison\_slab\_object mm/kasan/common.c:252 \[inline\]
   \_\_kasan\_slab\_free+0x5c/0x80 mm/kasan/common.c:284
   kasan\_slab\_free include/linux/kasan.h:234 \[inline\]
   slab\_free\_hook mm/slub.c:2533 \[inline\]
   slab\_free mm/slub.c:6622 \[inline\]
   kfree+0x19a/0x6d0 mm/slub.c:6829
   kvm\_set\_memory\_region+0x9c4/0xb90 virt/kvm/kvm\_main.c:2130
   kvm\_vm\_ioctl\_set\_memory\_region+0x6f/0xd0 virt/kvm/kvm\_main.c:2154
   kvm\_vm\_ioctl+0x957/0xc60 virt/kvm/kvm\_main.c:5201
   vfs\_ioctl fs/ioctl.c:51 \[inline\]
   \_\_do\_sys\_ioctl fs/ioctl.c:597 \[inline\]
   \_\_se\_sys\_ioctl+0xfc/0x170 fs/ioctl.c:583
   do\_syscall\_x64 arch/x86/entry/syscall\_64.c:63 \[inline\]
   do\_syscall\_64+0xfa/0xfa0 arch/x86/entry/syscall\_64.c:94
   entry\_SYSCALL\_64\_after\_hwframe+0x77/0x7f

Deliberately don't acquire filemap invalid lock when the file is dying as
the lifecycle of f\_mapping is outside the purview of KVM.  Dereferencing
the mapping is \*probably\* fine, but there's no need to invalidate anything
as memslot deletion is responsible for zapping SPTEs, and the only code
that can access the dying file is kvm\_gmem\_release(), whose core code is
mutual
---truncated---

## Affected and fixed versions

- Linux: \>= a7800aa80ea4d5356b8474c2302812e9d4926fa6, \< a8ac2bd0f98e1a230f1eb3260fa552bf2ef1753b; \>= a7800aa80ea4d5356b8474c2302812e9d4926fa6, \< 393893693a523e053f84d69320d090b93503f79f; \>= a7800aa80ea4d5356b8474c2302812e9d4926fa6, \< ae431059e75d36170a5ae6b44cc4d06d43613215 (cvelist)
- Linux: 6.8 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2025-40274.md
Affected: Linux >= a7800aa80ea4d5356b8474c2302812e9d4926fa6, < a8ac2bd0f98e1a230f1eb3260fa552bf2ef1753b; >= a7800aa80ea4d5356b8474c2302812e9d4926fa6, < 393893693a523e053f84d69320d090b93503f79f; >= a7800aa80ea4d5356b8474c2302812e9d4926fa6, < ae431059e75d36170a5ae6b44cc4d06d43613215; Linux 6.8
Fixed in: Linux 393893693a523e053f84d69320d090b93503f79f

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-2025-40274 being exploited?

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

### How serious is CVE-2025-40274?

High: CVSS 7.8 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2025-40274?

Linux \>= a7800aa80ea4d5356b8474c2302812e9d4926fa6, \< a8ac2bd0f98e1a230f1eb3260fa552bf2ef1753b; \>= a7800aa80ea4d5356b8474c2302812e9d4926fa6, \< 393893693a523e053f84d69320d090b93503f79f; \>= a7800aa80ea4d5356b8474c2302812e9d4926fa6, \< ae431059e75d36170a5ae6b44cc4d06d43613215; Linux 6.8.

### Is there a fix for CVE-2025-40274?

Yes. Fixed in Linux 393893693a523e053f84d69320d090b93503f79f. No fix listed yet: follow the vendor advisory.

### How do I check if I'm affected by CVE-2025-40274?

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

- other: <https://git.kernel.org/stable/c/a8ac2bd0f98e1a230f1eb3260fa552bf2ef1753b>
- other: <https://git.kernel.org/stable/c/393893693a523e053f84d69320d090b93503f79f>
- other: <https://git.kernel.org/stable/c/ae431059e75d36170a5ae6b44cc4d06d43613215>

## 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-2025-40274>

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