CVE-2024-40915

5.5 MEDIUM

📋 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

Products:
  • Linux kernel
Versions: Specific versions containing the vulnerable code (check git commits for exact ranges)
Operating Systems: Linux distributions running on RISC-V architecture
Default Config Vulnerable: ✅ No
Notes: Only vulnerable when CONFIG_DEBUG_PAGEALLOC is enabled and running on RISC-V hardware. Most production systems have this disabled by default.

📦 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.

🌐 Internet-Facing: LOW - This is a local kernel vulnerability requiring specific kernel configurations and RISC-V hardware.
🏢 Internal Only: MEDIUM - Could affect internal RISC-V servers with kernel debugging enabled, potentially causing service disruption.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: NO
Unauthenticated Exploit: ✅ No
Complexity: HIGH

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

linux

Disable 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

📤 Share & Export