CVE-2026-53162: Linux Kernel memcg NMI-Unsafe Random Number Generation Vulnerability
A vulnerability exists in the Linux kernel's memory control group (memcg) subsystem where random number generation used during memory pressure handling is unsafe in certain CPU contexts. When the kernel needs to free cached memory pages during high memory demand, it calls get_random_u32_below() to randomly select which memory cgroup should have its cache drained. However, this random function is not safe to use in NMI (non-maskable interrupt) handlers, which can fire at any time on a CPU. If an NMI occurs while the random number generator is mid-operation, it can corrupt the internal state used by that subsystem, potentially leading to unpredictable kernel behavior. The fix replaces random selection with a simple round-robin algorithm that cycles through memory cgroups in order, eliminating the need for unsafe random calls.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 7.8 HIGH · CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
- Weaknesses (CWE)
- —
- Affected products
- 7 configuration(s)
- Published / Modified
- 2026-06-25 / 2026-07-06
NVD description (verbatim)
In the Linux kernel, the following vulnerability has been resolved: memcg: use round-robin victim selection in refill_stock Harry Yoo reported that get_random_u32_below() is not safe to call in the nmi context and memcg charge draining can happen in nmi context. More specifically get_random_u32_below() is neither reentrant- nor NMI-safe: it acquires a per-cpu local_lock via local_lock_irqsave() on the batched_entropy_u32 state. An NMI that lands on a CPU mid-update of the ChaCha batch state and recurses into the random subsystem would corrupt that state. The memcg_stock local_trylock prevents re-entry on the percpu stock itself, but cannot protect an unrelated subsystem's per-cpu lock. Replace the random pick with a per-cpu round-robin counter stored in memcg_stock_pcp and serialized by the same local_trylock that already guards cached[] and nr_pages[]. No atomics, no random calls, no extra locks needed.
3 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The vulnerability stems from unsafe use of get_random_u32_below() in the memcg charge draining code path (refill_stock). This function internally uses per-CPU local locks (local_lock_irqsave on batched_entropy_u32 state) to protect ChaCha batch state updates. When memcg_stock's local_trylock triggers charge draining during NMI context, a concurrent NMI can interrupt the random subsystem's per-CPU operations mid-update, corrupting the entropy state. While memcg_stock's own local_trylock prevents re-entry on the memcg structure, it cannot protect the unrelated random subsystem's per-CPU lock. The patch replaces get_random_u32_below() with a simple per-CPU round-robin counter stored in memcg_stock_pcp and serialized by the existing local_trylock, eliminating the atomics, random calls, and potential lock conflicts.
Business impact
This vulnerability could allow an unprivileged local user to trigger kernel memory management instability through crafted system calls or workloads that induce simultaneous NMI events and memcg charge draining. Potential consequences include kernel crashes, denial of service, information disclosure from freed memory pages, or privilege escalation if memory corruption affects security-sensitive kernel structures. Systems under high memory pressure or with frequent NMI activity (such as performance monitoring or watchdog timers) are at elevated risk.
Affected systems
The Linux kernel across all distributions is affected. The vulnerability exists in the memcg subsystem code path active on systems using kernel memory cgroup controls (common in containerized and multi-tenant environments). Systems using cgroups v1 or v2 with memory constraints are in scope. This includes cloud infrastructure, container orchestration platforms, and systems running resource-isolated workloads.
Exploitability
Exploitation requires local system access and the ability to trigger both NMI events and memory pressure conditions simultaneously. The vulnerability does not require special privileges to invoke memcg draining through normal memory allocation patterns, but reliably triggering the race condition requires specific timing and knowledge of system configuration. The attack surface is moderate; it requires local access but can be triggered through standard system calls without kernel module loading or special capabilities.
Remediation
Apply kernel updates that replace the get_random_u32_below() call in the refill_stock function with the round-robin counter mechanism. Verify patch application by confirming memcg_stock_pcp includes the round-robin counter variable and the refill_stock function no longer calls get_random_u32_below() for victim selection. No kernel parameters or configuration changes are required post-patch.
Patch guidance
Update to a Linux kernel version that includes the memcg refill_stock fix. Verify the upstream commit resolving this issue is included in your distribution's kernel release. For custom or vendor kernels, confirm the patch cherry-picked into your branch. After kernel update, reboot to activate the fix. No live patching workarounds are available; full reboot is required. Test in non-production environments first, particularly on systems with memory cgroup configurations.
Detection guidance
Monitor kernel logs for memory-related crashes or warnings such as 'memory cgroup charge drain' errors or ChaCha entropy state corruption messages. Track NMI-related kernel panics, especially those occurring during high memory pressure periods. Use performance monitoring to correlate memcg activity with NMI frequency. On patched systems, verify the round-robin counter mechanism is in use by inspecting kernel symbols and code paths. Intrusion detection systems should flag unusual patterns of system calls triggering memory pressure followed by CPU exceptions.
Why prioritize this
HIGH priority due to CVSS 7.8 score and the potential for denial of service or privilege escalation through memory corruption. The vulnerability affects core kernel memory management, impacts all Linux systems using cgroups, and requires only local access to trigger. While exploitation requires specific conditions (NMI + charge draining race), the widespread use of cgroups in production infrastructure and containerized environments increases practical risk. Recommend patching within standard security update cycles.
Risk score, explained
CVSS 7.8 reflects a HIGH severity local privilege escalation vulnerability with high impact to confidentiality, integrity, and availability. The attack vector is local (AV:L), attack complexity is low (AC:L), and privileges required are low (PR:L), indicating an unprivileged user can exploit this. The scope is unchanged (S:U) and all CIA impacts are rated high (C:H/I:H/A:H) due to potential kernel corruption affecting memory isolation and system stability. The score does not account for the race condition complexity, which reduces practical exploitability slightly but does not change the severity assessment.
Frequently asked questions
Does this vulnerability require elevated privileges to exploit?
No. The vulnerability can be triggered by an unprivileged local user through normal system calls that induce memcg charge draining. However, reliable exploitation requires specific timing to trigger the NMI race condition, which may require some system knowledge or repeated attempts.
Which systems are most at risk?
Systems running containerized workloads, cloud VMs with resource limits, or multi-tenant environments using cgroups are at highest risk because they actively use memcg controls. Systems with frequent NMI activity (performance counters, watchdog timers, or specific CPU vendor firmware) face elevated exposure.
Can this be exploited remotely?
No. This is a local-only vulnerability requiring direct system access. Remote exploitation is not possible, but on multi-tenant or shared systems, an unprivileged tenant or user could exploit it against other users or the host kernel.
What is the difference between the vulnerable and patched behavior?
The vulnerable code uses get_random_u32_below() to randomly select which memory cgroup should have pages drained. This random function is unsafe in NMI context. The patch uses a simple per-CPU round-robin counter, eliminating the random number call and ensuring NMI-safe behavior without additional locking overhead.
This analysis is provided for informational purposes. The vulnerability details, CVSS score, and patch information are based on provided source data and upstream kernel disclosures. Organizations should verify patch versions against their distribution's official advisories and test updates in controlled environments before production deployment. No exploit code is provided; this document is for defensive awareness only. Consult your kernel vendor and distribution maintainer for final patch guidance specific to your systems. Source: NVD (public-domain), retrieved 2026-08-03. Analysis generated by SEC.co (claude-haiku-4-5).
Affected vendors
Related vulnerabilities
- CVE-2026-0270HIGHCortex XSOAR Path Traversal on Linux — Exploit Requirements & Patching Guide
- CVE-2026-0271HIGHPalo Alto Networks Prisma Access Agent Linux Privilege Escalation
- CVE-2026-10001HIGHChrome Sandbox Escape via PerformanceManager Use-After-Free
- CVE-2026-10002HIGHGoogle Chrome PDFium Use-After-Free Vulnerability (CVSS 8.8)
- CVE-2026-10003HIGHChrome Use-After-Free Code Execution Vulnerability Analysis
- CVE-2026-10006HIGHChrome WebAudio Race Condition Remote Code Execution
- CVE-2026-10007HIGHChrome Use-After-Free in SVG Arbitrary Code Execution (CVSS 8.8)
- CVE-2026-10009HIGHChrome Skia Integer Overflow Sandbox Escape – Patch Guidance