From mboxrd@z Thu Jan 1 00:00:00 1970 From: AL-KERNEL To: kernel-cve@kernelcve.org Subject: [CVE-2025-40040][MODERATE REGULAR] mm/ksm: fix flag-dropping behavior in ksm_madvise Date: Sun, 22 Nov 2026 04:29:58 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-AL-KERNEL-CVE: CVE-2025-40040 X-AL-KERNEL-Priority: MODERATE REGULAR X-AL-KERNEL-Severity: MODERATE REGULAR X-AL-KERNEL-Base-Severity: MODERATE X-AL-KERNEL-KPANIC: NO X-AL-KERNEL-ActionableScore: 3 X-AL-KERNEL-ActionableScore-Lower: unknown X-AL-KERNEL-Commit: 92b82e232b8d8b116ac6e57aeae7a6033db92c60 List-Id: CVE: CVE-2025-40040 Priority: MODERATE REGULAR AL-KERNEL base severity: MODERATE KPANIC flag: NO Patch: mm/ksm: fix flag-dropping behavior in ksm_madvise Commit: 92b82e232b8d8b116ac6e57aeae7a6033db92c60 Upstream patch: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=92b82e232b8d8b116ac6e57aeae7a6033db92c60 Original CVE announcement: https://lore.kernel.org/linux-cve-announce/?q=CVE-2025-40040 Analysis date: Sun, 22 Nov 2026 04:29:58 -0400 ActionableScore: 3 ActionableScore lower bound: unknown Actionable bucket: Borderline / manual review recommended Manual review required: YES Summary: A local user can clear upper VMA flags through `MADV_UNMERGEABLE`, creating userfaultfd state inconsistency that can trigger a kernel BUG during release. ====================================================================== ABOUT THIS REPORT ====================================================================== The original Linux kernel CVE announcement for CVE-2025-40040 is available here: https://lore.kernel.org/linux-cve-announce/?q=CVE-2025-40040 The original announcement does not normally provide a security severity estimate, CVSS assessment, or enough information to determine whether the reported kernel bug represents a practically relevant security issue. This report was generated by AL-KERNEL, an AI-assisted Linux kernel vulnerability analysis system developed by Alexander Larkin. It combines an autonomous classifier with LLM-assisted technical analysis and a separate ActionableScore mechanism. The purpose of this report is to prioritize Linux kernel CVEs before manual review, identify cases that require prompt investigation, and support automatic closure of issues that are unlikely to have meaningful security impact. Published priority for this report: MODERATE REGULAR Manual review required: YES A detailed explanation of the methodology and priority rules is included at the end of this message. ====================================================================== AL-KERNEL CLASSIFICATION RESULT ====================================================================== CVE-2025-40040 MODERATE https://www.kernelcve.org/list/?q=CVE-2025-40040 CHECK WITH IMPACT FROM ORIG NN LOW | AEGIS IMPACT MODERATE_KPANIC AEGIS_AS=1 LEGACY=MODERATE RESULT=DIFF (final Legacy and Aegis differ; FINAL: MODERATE, Aegis: MODERATE_KPANIC) Maybe valid. Check manually. Hints by AL-KERNEL: The best (paranoid) CVSS is 'AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H';CWE-681;CWE-704;CWE-682;Other CVSS 'AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H';BEST CVSS score: '6.6';DESCR 'The VM_MERGEABLE constant had a 32 bit unsigned type. As a result ksm_madvise with MADV_UNMERGEABLE could apply the mask 0x000000007fffffff to a 64 bit vm_flags value and unintentionally clear every flag in its upper 32 bits. A local user can reach the demonstrated failure by registering a supported VMA with userfaultfd MINOR mode and then applying MADV_UNMERGEABLE. This leaves a valid vm_userfaultfd_ctx pointer without the corresponding UFFD flags and userfaultfd_release_all can detect the inconsistency and trigger a kernel BUG or a later kernel WARNING. For the CVSS the PR:L value is selected because exploitation requires a local user context able to create the relevant mapping and invoke userfaultfd and madvise operations. The established impact is local denial of service through a kernel panic on affected versions. No UAF OOB access or arbitrary write primitive is demonstrated. Limited confidentiality or integrity impact remains a grounded worst case concern because multiple upper VMA metadata flags are cleared rather than only the intended KSM flag. Automated impact decision path. The original SimpleNet classifier selected LOW. The primary LLM estimated paranoid CVSS 6.6 and the production ActionableScore returned 3 with recommendation Borderline / manual review recommended. The production rules then evaluated CVSS thresholds and ActionableScore thresholds. Recorded rule transitions were CVSS and initial triage stage LOW to MODERATE_KPANIC because the manual review requirement was applied. ActionableScore thresholds stage MODERATE_KPANIC to MODERATE because the ActionableScore threshold rule was applied. The legacy KP specialist has no review artifact for this run. The legacy FD or DH downgrade specialist has no review artifact for this run. Exact triggered rule markers were INCREASED_FROM_LOW_BASED_ON_REQUIREMANUALCHECK and DECREASED_TO_MODERATEREG_BASED_ON_ACTIONABLESCORELESSTHAN4 and V41_INHERITED_KPANIC_PROMOTION_BLOCKED and MANUAL_REVIEW_REQUIRED. The independent weaker Aegis shadow evaluated CVSS 6.5 and ActionableScore 1 with primitive class CLASS_C and manual review REQUIRED. Its independently reconciled impact was MODERATE_KPANIC. The models disagreed but the aggregation rules retained the production result. The final reported impact is MODERATE.';YES REQUIRES MANUAL CHECK; ,and ActionableScore result is Borderline / manual review recommended (with actual score 3) MAYBE KASAN LEAK HARDWARE INCREASED_FROM_LOW_BASED_ON_REQUIREMANUALCHECK DECREASED_TO_MODERATEREG_BASED_ON_ACTIONABLESCORELESSTHAN4 V41_INHERITED_KPANIC_PROMOTION_BLOCKED MANUAL_REVIEW_REQUIRED - - checked ====================================================================== ACTIONABLESCORE ANALYSIS ====================================================================== ActionableScore=3 PrimitiveClass=CLASS_C RealUAF=NO HostAdminRequired=NO NamespaceScopedPrivilege=NO ImportantCandidate=NO ManualReview=RECOMMENDED AutoDowngradeAllowed=YES RequiresHostUID0=NO AuthorizationDecisionBypass=NO ProtectedResourceImpact=NONE B4PendingReview=NO B4PendingConfirmed=NO 1. ActionableScore * Raw base score: 3. * Conservative score: 3; no floor or cap applied. * Raw paranoid score: 3. * Paranoid score: 3; no separate downstream corrupt primitive is evidenced. * Final recommended bucket: **Borderline / manual review recommended**:: 2. Signal breakdown * +1 Local unprivileged trigger: supplied evidence grounds a local user registering a supported VMA for userfaultfd MINOR mode and invoking `MADV_UNMERGEABLE`. * +1 Weak/indirect structured-state corruption: the malformed 32-bit complement clears the upper half of the active 64-bit `vm_flags`, leaving `vm_userfaultfd_ctx` inconsistent with its UFFD flags. * +1 Reliable kernel crash/strong DoS: affected versions reach a `BUG` in `userfaultfd_release_all()`; newer code emits a warning instead. * No additional availability point: it would duplicate the same BUG/Oops. * No UAF, OOB access, arbitrary write, controlled reclaim, disclosure, protected-state integrity impact, or authorization bypass is shown. * No paranoid point: although several upper VMA flags can be cleared, no specific later consumer producing a separate security effect is supplied. * B5-R and B3-PENDING do not apply: there is no heap OOB write or shared-backing write. 3. Reachability analysis The demonstrated sequence is local and attributed to an ordinary user context; neither host UID 0 nor an administrative capability is shown as required. No namespace capability or prior privileged setup is involved. A supported userfaultfd MINOR mapping and KSM madvise path are prerequisites, but no race, special hardware, or retry sequence is required. 4. Primitive and severity reading The exact primitive is attacker-invoked corruption of active VMA flag metadata through incorrect integer-width promotion. Its proven downstream consumer detects a UFFD context/flag inconsistency during file release and triggers a BUG or warning. This is not a lifetime violation or memory overwrite, so it is CLASS_C. Stronger effects from other cleared flags remain unproven and lack a specific consumer or trust-boundary chain. ImportantCandidate is therefore NO, while manual review remains appropriate because multiple active metadata bits are dropped. Auto-downgrade is allowed because the established impact is crash/invalid-state behavior without an unresolved material exploit primitive. 5. One-sentence report phrase A local user can clear upper VMA flags through `MADV_UNMERGEABLE`, creating userfaultfd state inconsistency that can trigger a kernel BUG during release. 6. Manual review advice MANUAL CHECK RECOMMENDED Confirm product exposure to unprivileged userfaultfd MINOR registration and whether any product-specific high VMA flags have security-relevant consumers before the inconsistency is detected. 7. Call-site confidence Call-site confidence: high ====================================================================== UPSTREAM PATCH SUMMARY ====================================================================== Patch: mm/ksm: fix flag-dropping behavior in ksm_madvise Commit: 92b82e232b8d8b116ac6e57aeae7a6033db92c60 Upstream URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=92b82e232b8d8b116ac6e57aeae7a6033db92c60 Commit description: 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 [ 44.617726] Call Trace: [ 44.617926] [ 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 31defc3 ("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] Link: https://lore.kernel.org/oe-kbuild-all/202510030449.VfSaAjvd-lkp@intel.com/ Link: https://lkml.kernel.org/r/20251001090353.57523-2-acsjakub@amazon.de Fixes: 7677f7f ("userfaultfd: add minor fault registration mode") Signed-off-by: Jakub Acs Signed-off-by: Miguel Ojeda Acked-by: David Hildenbrand Acked-by: SeongJae Park Tested-by: Alice Ryhl Tested-by: Miguel Ojeda Cc: Xu Xin Cc: Chengming Zhou Cc: Peter Xu Cc: Axel Rasmussen Cc: Signed-off-by: Andrew Morton [acsjakub@amazon.de: adapt rust bindgen const to older versions] Signed-off-by: Jakub Acs Signed-off-by: Greg Kroah-Hartman Changed files: mm/userfaultfd.c include/linux/mm.h rust/bindings/bindings_helper.h rust/bindings/lib.rs Diff excerpt: Not included in this email. See the upstream URL for the full patch. Full patch: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=92b82e232b8d8b116ac6e57aeae7a6033db92c60 ====================================================================== DETAILED REPORT METHODOLOGY ====================================================================== The original Linux kernel CVE announcement for CVE-2025-40040 can be found here: https://lore.kernel.org/linux-cve-announce/?q=CVE-2025-40040 The original CVE announcement normally does not include a security-level estimate. In particular, it may not contain a CVSS assessment, an impact level, or enough information to determine whether the reported bug is a practically relevant security issue. One purpose of this parallel CVE list is to provide that missing technical and prioritization information. The original goal of the AL-KERNEL project was to prioritize Linux kernel CVE analysis automatically before manual review. The system can also help identify non-security issues that may be suitable for automatic closure. This report was generated by AL-KERNEL, an AI-assisted Linux kernel vulnerability analysis system developed by Alexander Larkin. The first analysis stage combines an autonomous classifier with additional LLM-based analysis. The autonomous classifier runs locally on a CPU and is based on a backpropagation neural network. Together, these mechanisms produce a technical vulnerability description, identify likely weakness types, estimate CVSS severity, and provide input for ActionableScore. Two CVSS estimates are retained because incomplete kernel vulnerability information often permits more than one defensible interpretation: Conservative CVSS vector: AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H The Best / paranoid CVSS vector: AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H The Best / paranoid CVSS score: 6.6 The conservative vector represents a lower-impact interpretation. The Best/paranoid vector intentionally represents a plausible upper-bound interpretation and should not automatically be treated as demonstrated real-world impact. CVSS may also need to be adjusted for a particular Linux deployment, because actual reachability, privileges, enabled kernel configuration, hardware, namespaces, exposed device nodes, and other environmental conditions can differ significantly between systems. A separate ActionableScore mechanism evaluates practical remediation urgency. Its analysis may include reachability, attack prerequisites, subsystem exposure, memory-corruption characteristics, denial-of-service reliability, and possible confidentiality, integrity, or privilege-escalation impact. Conservative ActionableScore: unknown Paranoid ActionableScore: 3 The final base severity is taken directly from the second tab-separated field of the AL-KERNEL classification result. ActionableScore does not replace or independently override that final AL-KERNEL decision, and if ActionableScore adjusted impact level of ALKERNEL, then you would see self-readable flags above like INCREASED_TO_HIGH_BASED_ON_ACTIONABLESCOREHIGHEREQTHAN7. For an AL-KERNEL result of MODERATE, this report uses the following additional presentation split: ActionableScore below 5 -> MODERATE REGULAR ActionableScore 5 or more -> MODERATE 7.0 The distinction between MODERATE REGULAR and MODERATE 7.0 makes it possible to identify Moderate issues that should receive manual analysis and fixes before lower-priority MODERATE REGULAR issues. In many cases, MODERATE REGULAR fixes may wait for a later rebase or routine update. There is one override in which MODERATE REGULAR becomes MODERATE 7.0 even when the ActionableScore is below 5. When the AL-KERNEL result contains the KPANIC flag, a MODERATE result is always presented as MODERATE 7.0. The KPANIC flag selected with few regexps without usage of AI at all, so it helps to detect cases when Kernel Crash happens and similar (to filter False-Negative results from the LLM usage). KPANIC indicates that a reliable kernel crash, kernel panic, or similarly serious kernel availability impact was identified by the classification workflow. AL-KERNEL base severity for this report: MODERATE KPANIC detected for this report: NO Published priority for this report (same as in Subject): MODERATE REGULAR These results are intended to support engineering triage. They are machine-generated estimates, and cases marked for manual review should be validated by a human security engineer before final disposition. For more info read docs linked from here: https://kernelcve.org/ (and you can submit you own patch there to generate such a report for non-existant CVE-id yet). Note that in many cases this AI tool selects higher severity, than real is (means you can expect Importants instead of Moderate 7.0 or Moderates 7.0 instead of regular Moderates). If you see such cases, please use reply email interface to add additional manual analyses info to this particular CVE. And please, please, let me know when you see Lows instead of Importants or Important instead of Low (because particular for such cases I need to tune this AI tool to make it better for this one and next similar). My contact email for such notifications is alexanjelausa@gmail.com (and both send reply to CVE record itself too and see "reply" button below for howto reply).