CVE-2024-40915
📋 TL;DR
This CVE describes a race condition vulnerability in the Linux kernel's RISC-V architecture where the __kernel_map_pages() debug function could sleep while holding a semaphore in atomic context, potentially causing kernel panics or system instability. It affects Linux systems running on RISC-V hardware with kernel debugging features enabled. The vulnerability requires specific kernel configurations to be exploitable.
💻 Affected Systems
- Linux kernel
📦 What is this software?
Linux Kernel by Linux
The Linux Kernel is the core component of the Linux operating system, serving as the critical interface between computer hardware and software processes. As the heart of millions of servers, cloud infrastructure, embedded systems, Android devices, and IoT deployments worldwide, the Linux Kernel mana...
Learn more about Linux Kernel →Linux Kernel by Linux
The Linux Kernel is the core component of the Linux operating system, serving as the critical interface between computer hardware and software processes. As the heart of millions of servers, cloud infrastructure, embedded systems, Android devices, and IoT deployments worldwide, the Linux Kernel mana...
Learn more about Linux Kernel →Linux Kernel by Linux
The Linux Kernel is the core component of the Linux operating system, serving as the critical interface between computer hardware and software processes. As the heart of millions of servers, cloud infrastructure, embedded systems, Android devices, and IoT deployments worldwide, the Linux Kernel mana...
Learn more about Linux Kernel →⚠️ Risk & Real-World Impact
Worst Case
Kernel panic leading to system crash and denial of service, potentially causing data loss or service disruption.
Likely Case
System instability or kernel warnings when memory debugging features are active, possibly leading to performance degradation.
If Mitigated
No impact if kernel debugging features are disabled or the system is not using RISC-V architecture.
🎯 Exploit Status
Exploitation requires specific kernel configurations and RISC-V hardware. This appears to be a stability issue rather than a security bypass.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Patched in kernel commits 8661a7af04991201640863ad1a0983173f84b5eb and related
Vendor Advisory: https://git.kernel.org/stable/c/8661a7af04991201640863ad1a0983173f84b5eb
Restart Required: Yes
Instructions:
1. Update Linux kernel to version containing the fix. 2. For RISC-V systems: Check if CONFIG_DEBUG_PAGEALLOC is enabled. 3. Apply kernel patches from upstream. 4. Reboot system to load new kernel.
🔧 Temporary Workarounds
Disable DEBUG_PAGEALLOC
linuxDisable kernel page allocation debugging feature which triggers the vulnerable code path
echo 'kernel.page_alloc.debug = 0' >> /etc/sysctl.conf
sysctl -p
🧯 If You Can't Patch
- Disable CONFIG_DEBUG_PAGEALLOC in kernel configuration and rebuild kernel
- Avoid using RISC-V systems with kernel debugging features enabled in production environments
🔍 How to Verify
Check if Vulnerable:
Check kernel config: grep CONFIG_DEBUG_PAGEALLOC /boot/config-$(uname -r) and check if running on RISC-V: uname -m
Check Version:
uname -r
Verify Fix Applied:
Check kernel version contains fix commits: uname -r and verify with git log
📡 Detection & Monitoring
Log Indicators:
- Kernel logs showing 'sleeping function called from invalid context'
- BUG: sleeping function called from invalid context warnings
Network Indicators:
- None - this is a local kernel issue
SIEM Query:
source="kernel" AND "sleeping function called from invalid context" AND "__kernel_map_pages"
🔗 References
- https://git.kernel.org/stable/c/8661a7af04991201640863ad1a0983173f84b5eb
- https://git.kernel.org/stable/c/919f8626099d9909b9a9620b05e8c8ab06581876
- https://git.kernel.org/stable/c/d5257ceb19d92069195254866421f425aea42915
- https://git.kernel.org/stable/c/fb1cf0878328fe75d47f0aed0a65b30126fcefc4
- https://git.kernel.org/stable/c/8661a7af04991201640863ad1a0983173f84b5eb
- https://git.kernel.org/stable/c/919f8626099d9909b9a9620b05e8c8ab06581876
- https://git.kernel.org/stable/c/d5257ceb19d92069195254866421f425aea42915
- https://git.kernel.org/stable/c/fb1cf0878328fe75d47f0aed0a65b30126fcefc4
- https://lists.debian.org/debian-lts-announce/2025/01/msg00001.html