cve.bz

CVE-2025-40040 linux linux kernel

5.5 mediumEPSS 0.4%Fix available

Medium (5.5) in linux linux kernel. EPSS 0.4% estimated probability of exploitation activity in the next 30 days.

On this page
In the Linux kernel, the following vulnerability has been resolved: mm/ksm: fix flag-dropping behavior in ksm_madvise syzkaller discovered the following crash: (kernel BUG) [ 44.607039] ------------[ cut here ]------------ [ 44.607422] kernel BUG at mm/userfaultfd.c:2067! [ 44.608148] Oops: invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN NOPTI [ 44.608814] CPU: 1 UID: 0 PID: 2475 Comm: reproducer Not tainted 6.16.0-rc6 #1 PREEMPT(none) [ 44.609635] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014 [ 44.610695] RIP: 0010:userfaultfd_release_all+0x3a8/0x460 <snip other registers, drop unreliable trace> [ 44.617726] Call Trace: [ 44.617926] <TASK> [ 44.619284] userfaultfd_release+0xef/0x1b0 [ 44.620976] __fput+0x3f9/0xb60 [ 44.621240] fput_close_sync+0x110/0x210 [ 44.622222] __x64_sys_close+0x8f/0x120 [ 44.622530] do_syscall_64+0x5b/0x2f0 [ 44.622840] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 44.623244] RIP: 0033:0x7f365bb3f227 Kernel panics because it detects UFFD inconsistency during userfaultfd_release_all(). Specifically, a VMA which has a valid pointer to vma->vm_userfaultfd_ctx, but no UFFD flags in vma->vm_flags. The inconsistency is caused in ksm_madvise(): when user calls madvise() with MADV_UNMEARGEABLE on a VMA that is registered for UFFD in MINOR mode, it accidentally clears all flags stored in the upper 32 bits of vma->vm_flags. Assuming x86_64 kernel build, unsigned long is 64-bit and unsigned int and int are 32-bit wide. This setup causes the following mishap during the &= ~VM_MERGEABLE assignment. VM_MERGEABLE is a 32-bit constant of type unsigned int, 0x8000'0000. After ~ is applied, it becomes 0x7fff'ffff unsigned int, which is then promoted to unsigned long before the & operation. This promotion fills upper 32 bits with leading 0s, as we're doing unsigned conversion (and even for a signed conversion, this wouldn't help as the leading bit is 0). & operation thus ends up AND-ing vm_flags with 0x0000'0000'7fff'ffff instead of intended 0xffff'ffff'7fff'ffff and hence accidentally clears the upper 32-bits of its value. Fix it by changing `VM_MERGEABLE` constant to unsigned long, using the BIT() macro. Note: other VM_* flags are not affected: This only happens to the VM_MERGEABLE flag, as the other VM_* flags are all constants of type int and after ~ operation, they end up with leading 1 and are thus converted to unsigned long with leading 1s. Note 2: After commit 31defc3b01d9 ("userfaultfd: remove (VM_)BUG_ON()s"), this is no longer a kernel BUG, but a WARNING at the same place: [ 45.595973] WARNING: CPU: 1 PID: 2474 at mm/userfaultfd.c:2067 but the root-cause (flag-drop) remains the same. [akpm@linux-foundation.org: rust bindgen wasn't able to handle BIT(), from Miguel]

Severity

CVSS 3.1

5.5 medium
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
EPSS
0.4% (unchanged from 0.4% a week ago; 0.4% 30 days ago) estimated probability of exploitation activity in the next 30 days; 32nd percentile. Scored 2026-11-15. A forecast for this CVE across the internet, not for your own systems.
CISA's assessment (SSVC)
Exploitation: none · Automatable: no · Technical impact: total, assessed 2026-10-15. From CISA's Vulnrichment in the CVE List: whether it is exploited, whether exploiting it can be automated, and how much control it gives.
Published
Modified
NVD analysis
Analyzed, since modified
Record from
the NVD, synced

Fix and patched versions

Ask an AI about this CVE

Show the promptExplain CVE-2025-40040 for an engineer deciding whether to act. Use https://cve.bz/api/public/cves/CVE-2025-40040?via=ask-ai-copy and https://cve.bz/cve/CVE-2025-40040?via=ask-ai-copy as the source of truth: what is affected and which versions fix it, whether it is in CISA KEV, public exploits, and its EPSS (an internet-wide 30-day estimate of exploitation activity, not a forecast for my systems). If they give no fixed versions, use the CVE record https://cveawg.mitre.org/api/cve/CVE-2025-40040 or the vendor advisory, not third-party mirrors. Tell me how to check whether I am affected and how to verify a fix. Cite the sources and say where they are uncertain.

Opens a third-party assistant; its answer is its own, not cve.bz's. The prompt holds only this CVE's id and public links.

Affected

Versions

From the CNA's record in the CVE List.

ProductAffected
Linux4.6 and later

Fixed in

ProductRelease lineFixed in
Linux5.45.4.302
Linux5.105.10.247
Linux5.155.15.197
Linux6.16.1.158
Linux6.66.6.114
Linux6.126.12.55
Linux6.176.17.3
Linuxlater releases6.18

Linux distributions

DistributionReleasePackageFixed inAdvisory
Debian11linux-6.16.1.158-1~deb11u1DLA-4379-1
Debian12linux6.1.158-1DEBIAN-CVE-2025-40040 DSA-6053-1
Debian13linux6.12.57-1DEBIAN-CVE-2025-40040
Debian14linux6.17.6-1DEBIAN-CVE-2025-40040
Ubuntu16.04:LTSlinux-hwe-edgeno fix listedUBUNTU-CVE-2025-40040
Ubuntu18.04:LTSlinux-gcp, linux-hwe, linux-oem and 12 moreno fix listedUBUNTU-CVE-2025-40040
Ubuntu20.04:LTSlinux-gke, linux-gkeop, linux-riscv and 26 moreno fix listedUBUNTU-CVE-2025-40040
Ubuntu22.04:LTSlinux, linux-lowlatency5.15.0-173.183UBUNTU-CVE-2025-40040 USN-8096-1
Ubuntu22.04:LTSlinux-aws5.15.0-1103.110UBUNTU-CVE-2025-40040 USN-8096-1
Ubuntu22.04:LTSlinux-azure5.15.0-1109.118UBUNTU-CVE-2025-40040 USN-8163-2
Ubuntu22.04:LTSlinux-azure-fde5.15.0-1109.118.1UBUNTU-CVE-2025-40040
Ubuntu22.04:LTSlinux-gcp5.15.0-1103.112UBUNTU-CVE-2025-40040 USN-8096-1
Ubuntu22.04:LTSlinux-gke5.15.0-1099.105UBUNTU-CVE-2025-40040 USN-8096-3
Ubuntu22.04:LTSlinux-gkeop5.15.0-1086.94UBUNTU-CVE-2025-40040 USN-8096-1
Ubuntu22.04:LTSlinux-ibm, linux-raspi5.15.0-1097.100UBUNTU-CVE-2025-40040 USN-8096-1 USN-8141-1
Ubuntu22.04:LTSlinux-intel-iotg5.15.0-1098.104UBUNTU-CVE-2025-40040 USN-8096-1
40 more for Ubuntu in the JSON and on Ubuntu's page.
SUSEEnterprise Storage 7.1, Linux Enterprise High Performance Computing 15 SP3-LTSSkernel-64kb, kernel-source, kernel-default and 2 more5.3.18-150300.59.229.3SUSE-SU-2025:4530-1
SUSEEnterprise Storage 7.1, Linux Enterprise High Performance Computing 15 SP3-LTSS, Linux Enterprise Micro 5.2 and 2 morekernel-default-base5.3.18-150300.59.229.3.150300.18.136.3SUSE-SU-2025:4530-1
SUSEEnterprise Storage 7.1, Linux Enterprise High Performance Computing 15 SP3-LTSS, Linux Enterprise Server 15 SP3-LTSS and 1 morekernel-docs5.3.18-150300.59.229.2SUSE-SU-2025:4530-1
SUSEEnterprise Storage 7.1, Linux Enterprise High Performance Computing 15 SP3-LTSS, Linux Enterprise Server 15 SP3-LTSS and 1 morekernel-syms5.3.18-150300.59.229.1SUSE-SU-2025:4530-1
SUSELinux Enterprise High Availability Extension 15 SP3, Linux Enterprise Live Patching 15 SP3, Linux Enterprise Micro 5.2kernel-default5.3.18-150300.59.229.3SUSE-SU-2025:4530-1
SUSELinux Enterprise High Availability Extension 15 SP4, Linux Enterprise Live Patching 15 SP4, Linux Enterprise Micro 5.3 and 1 morekernel-default5.14.21-150400.24.187.3SUSE-SU-2026:0029-1
SUSELinux Enterprise High Availability Extension 15 SP6, Linux Enterprise Live Patching 15 SP6, Linux Enterprise Module for Legacy 15 SP6 and 1 morekernel-default6.4.0-150600.23.81.3SUSE-SU-2025:4422-1
SUSELinux Enterprise High Availability Extension 15 SP7, Linux Enterprise Live Patching 15 SP7, Linux Enterprise Module for Legacy 15 SP7 and 1 morekernel-default6.4.0-150700.53.25.1SUSE-SU-2025:4393-1
SUSELinux Enterprise High Availability Extension 16.0kernel-default6.12.0-160000.7.1SUSE-SU-2025:21180-1
SUSELinux Enterprise High Performance Computing 15 SP4-ESPOS, Linux Enterprise High Performance Computing 15 SP4-LTSSkernel-64kb, kernel-source, kernel-default and 1 more5.14.21-150400.24.187.3SUSE-SU-2026:0029-1
SUSELinux Enterprise High Performance Computing 15 SP4-ESPOS, Linux Enterprise High Performance Computing 15 SP4-LTSS, Linux Enterprise Micro 5.3 and 5 morekernel-default-base5.14.21-150400.24.187.3.150400.24.96.3SUSE-SU-2026:0029-1
SUSELinux Enterprise High Performance Computing 15 SP4-ESPOS, Linux Enterprise High Performance Computing 15 SP4-LTSS, Linux Enterprise Server 15 SP4-LTSS and 1 morekernel-docs, kernel-syms5.14.21-150400.24.187.1SUSE-SU-2026:0029-1
54 more for SUSE in the JSON and on SUSE's page.
openSUSELeap 15.6dtb-aarch64, kernel-docs, kernel-syms and 1 more6.4.0-150600.23.81.1SUSE-SU-2025:4422-1
openSUSELeap 15.6kernel-64kb, kernel-debug, kernel-default and 3 more6.4.0-150600.23.81.3SUSE-SU-2025:4422-1
openSUSELeap 15.6kernel-azure, kernel-syms-azure, kernel-source-azure6.4.0-150600.8.58.1SUSE-SU-2025:4505-1
openSUSELeap 15.6kernel-default-base6.4.0-150600.23.81.3.150600.12.36.3SUSE-SU-2025:4422-1
openSUSELeap 15.6kernel-rt, kernel-syms-rt, kernel-rt_debug and 1 more6.4.0-150600.10.61.1SUSE-SU-2025:4521-1
openSUSELeap 15.6kernel-source6.4.0-150600.23.81.2SUSE-SU-2025:4422-1
openSUSELeap 16.0kernel-default-base6.12.0-160000.6.1.160000.2.4openSUSE-SU-2025:20091-1
openSUSELeap 16.0kernel-rt, dtb-aarch64, kernel-64kb and 8 more6.12.0-160000.7.1openSUSE-SU-2025:20091-1
openSUSETumbleweedkernel-source6.17.7-1.1openSUSE-SU-2025:15702-1
openSUSETumbleweedkernel-source-longterm6.18.16-1.1openSUSE-SU-2026:10301-1
Azure Linux2kernel5.15.200.1-1AZL-78386
Azure Linux3kernel6.6.117.1-1AZL-68870
Alpaquita23linux-lts6.1.158-r0BELL-CVE-2025-40040
Alpaquita25linux-lts6.12.57-r0BELL-CVE-2025-40040
Alpaquitastreamlinux-lts6.18.35-r1BELL-CVE-2025-40040

From the distributions' data via OSV.dev: the Debian Security Tracker; Ubuntu Security Notices © Canonical Ltd., CC BY-SA 4.0; SUSE security data, CC BY 4.0; Microsoft's Azure Linux vulnerability data, MIT; BellSoft's OSV database, MIT. Modified: reformatted and linked to CVE records. Credits. On the distributions' own pages: Debian · Ubuntu · SUSE · openSUSE · Alpaquita.

Red Hat

Red Hat rates this Moderate.

Red Hat's statement

This vulnerability is rated as Moderate because triggering the issue requires local access to execute specific memory advisory and userfaultfd system calls, limiting the risk primarily to a local denial of service. When an application attempts to mark registered memory ranges as unmergeable, improper type conversion inside the kernel memory management subsystem inadvertently strips high-order virtual memory flags. This flag corruption results in an inconsistent internal kernel state that can induce a kernel panic or trigger warnings during resource cleanup. Because exploitation cannot be achieved remotely and does not directly permit privilege escalation or information disclosure, the overall severity is kept at Moderate.

Red Hat's mitigation

Mitigation for this issue is either not available or the currently available options don't meet the Red Hat Product Security criteria comprising ease of use and deployment, applicability to widespread installation base or stability.

ProductPackageStateAdvisory
Red Hat Enterprise Linux 10kernelAffected
Red Hat Enterprise Linux 6kernelOut of support scope
Red Hat Enterprise Linux 7kernelNot affected
Red Hat Enterprise Linux 7kernel-rtNot affected
Red Hat Enterprise Linux 8kernelNot affected
Red Hat Enterprise Linux 8kernel-rtNot affected
Red Hat Enterprise Linux 9kernelAffected
Red Hat Enterprise Linux 9kernel-rtAffected

Contains Red Hat Security Data © Red Hat, Inc., licensed under CC BY 4.0. Source: https://access.redhat.com/security/data. Modified: reformatted. Red Hat's page for CVE-2025-40040.

GitHub PoC (unverified)

Repositories on GitHub named after this CVE. Nobody has checked them and they are not scanned: some hold a working proof of concept, some nothing useful, and some malware made to look like one. Read the code before you run any of it.

References

Check your stackJSON