Skip to main content

CVE-2024-27031: Vulnerability in Linux Linux

High
VulnerabilityCVE-2024-27031cvecve-2024-27031
Published: Wed May 01 2024 (05/01/2024, 12:53:29 UTC)
Source: CVE
Vendor/Project: Linux
Product: Linux

Description

In the Linux kernel, the following vulnerability has been resolved: NFS: Fix nfs_netfs_issue_read() xarray locking for writeback interrupt The loop inside nfs_netfs_issue_read() currently does not disable interrupts while iterating through pages in the xarray to submit for NFS read. This is not safe though since after taking xa_lock, another page in the mapping could be processed for writeback inside an interrupt, and deadlock can occur. The fix is simple and clean if we use xa_for_each_range(), which handles the iteration with RCU while reducing code complexity. The problem is easily reproduced with the following test: mount -o vers=3,fsc 127.0.0.1:/export /mnt/nfs dd if=/dev/zero of=/mnt/nfs/file1.bin bs=4096 count=1 echo 3 > /proc/sys/vm/drop_caches dd if=/mnt/nfs/file1.bin of=/dev/null umount /mnt/nfs On the console with a lockdep-enabled kernel a message similar to the following will be seen: ================================ WARNING: inconsistent lock state 6.7.0-lockdbg+ #10 Not tainted -------------------------------- inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage. test5/1708 [HC0[0]:SC0[0]:HE1:SE1] takes: ffff888127baa598 (&xa->xa_lock#4){+.?.}-{3:3}, at: nfs_netfs_issue_read+0x1b2/0x4b0 [nfs] {IN-SOFTIRQ-W} state was registered at: lock_acquire+0x144/0x380 _raw_spin_lock_irqsave+0x4e/0xa0 __folio_end_writeback+0x17e/0x5c0 folio_end_writeback+0x93/0x1b0 iomap_finish_ioend+0xeb/0x6a0 blk_update_request+0x204/0x7f0 blk_mq_end_request+0x30/0x1c0 blk_complete_reqs+0x7e/0xa0 __do_softirq+0x113/0x544 __irq_exit_rcu+0xfe/0x120 irq_exit_rcu+0xe/0x20 sysvec_call_function_single+0x6f/0x90 asm_sysvec_call_function_single+0x1a/0x20 pv_native_safe_halt+0xf/0x20 default_idle+0x9/0x20 default_idle_call+0x67/0xa0 do_idle+0x2b5/0x300 cpu_startup_entry+0x34/0x40 start_secondary+0x19d/0x1c0 secondary_startup_64_no_verify+0x18f/0x19b irq event stamp: 176891 hardirqs last enabled at (176891): [<ffffffffa67a0be4>] _raw_spin_unlock_irqrestore+0x44/0x60 hardirqs last disabled at (176890): [<ffffffffa67a0899>] _raw_spin_lock_irqsave+0x79/0xa0 softirqs last enabled at (176646): [<ffffffffa515d91e>] __irq_exit_rcu+0xfe/0x120 softirqs last disabled at (176633): [<ffffffffa515d91e>] __irq_exit_rcu+0xfe/0x120 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(&xa->xa_lock#4); <Interrupt> lock(&xa->xa_lock#4); *** DEADLOCK *** 2 locks held by test5/1708: #0: ffff888127baa498 (&sb->s_type->i_mutex_key#22){++++}-{4:4}, at: nfs_start_io_read+0x28/0x90 [nfs] #1: ffff888127baa650 (mapping.invalidate_lock#3){.+.+}-{4:4}, at: page_cache_ra_unbounded+0xa4/0x280 stack backtrace: CPU: 6 PID: 1708 Comm: test5 Kdump: loaded Not tainted 6.7.0-lockdbg+ Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-1.fc39 04/01/2014 Call Trace: dump_stack_lvl+0x5b/0x90 mark_lock+0xb3f/0xd20 __lock_acquire+0x77b/0x3360 _raw_spin_lock+0x34/0x80 nfs_netfs_issue_read+0x1b2/0x4b0 [nfs] netfs_begin_read+0x77f/0x980 [netfs] nfs_netfs_readahead+0x45/0x60 [nfs] nfs_readahead+0x323/0x5a0 [nfs] read_pages+0xf3/0x5c0 page_cache_ra_unbounded+0x1c8/0x280 filemap_get_pages+0x38c/0xae0 filemap_read+0x206/0x5e0 nfs_file_read+0xb7/0x140 [nfs] vfs_read+0x2a9/0x460 ksys_read+0xb7/0x140

AI-Powered Analysis

AILast updated: 06/29/2025, 14:39:30 UTC

Technical Analysis

CVE-2024-27031 is a vulnerability identified in the Linux kernel's Network File System (NFS) implementation, specifically within the function nfs_netfs_issue_read(). This function is responsible for iterating through pages in an xarray data structure to submit read requests for NFS. The vulnerability arises because the iteration loop does not disable interrupts while processing these pages. Consequently, after acquiring the xa_lock (a lock protecting the xarray), an interrupt could trigger writeback processing on another page within the same mapping. This unsafe locking scenario can lead to a deadlock condition, where the kernel is stuck waiting for locks held by itself in an interrupt context. The issue is reproducible by mounting an NFS share, performing a write operation, dropping caches, reading the file back, and unmounting, which triggers lockdep warnings about inconsistent lock states and potential deadlocks. The root cause is the lack of proper interrupt disabling during the iteration, which allows nested locking attempts on the same xa_lock from interrupt context. The fix involves replacing the manual iteration with xa_for_each_range(), which safely handles iteration under Read-Copy-Update (RCU) synchronization, reducing complexity and preventing deadlocks. This vulnerability affects Linux kernel versions prior to the patch and is relevant to systems using NFS for networked file access. No known exploits are currently reported in the wild, and no CVSS score has been assigned yet.

Potential Impact

For European organizations, this vulnerability poses a risk primarily to servers and infrastructure relying on NFS for file sharing and storage, which is common in enterprise environments, data centers, and cloud providers. A deadlock in the kernel can cause system hangs or crashes, leading to denial of service (DoS) conditions. This can disrupt critical business operations, especially in sectors like finance, manufacturing, research, and government services where NFS is used for shared storage. The impact extends to any Linux-based systems acting as NFS clients or servers, potentially affecting availability and operational continuity. While this vulnerability does not directly expose confidentiality or integrity risks, the resulting DoS can indirectly affect service reliability and data accessibility. Given the widespread use of Linux and NFS in Europe, the vulnerability could have a broad operational impact if exploited or triggered unintentionally. However, exploitation requires specific conditions and kernel configurations, and no active exploitation has been reported, which somewhat limits immediate risk.

Mitigation Recommendations

European organizations should prioritize updating their Linux kernels to versions where this vulnerability is patched. Since the fix involves changes to kernel locking and iteration mechanisms, applying official kernel updates from trusted Linux distributions is the most effective mitigation. Organizations should: 1) Identify all Linux systems using NFS, especially those running kernel versions prior to the patch date (before May 2024). 2) Schedule and perform kernel upgrades during maintenance windows to minimize disruption. 3) Enable and monitor kernel lock debugging tools (like lockdep) to detect potential deadlocks early. 4) Review and limit the use of NFS where possible, considering alternative file sharing protocols or configurations that reduce reliance on vulnerable kernel code paths. 5) Implement robust monitoring and alerting for system hangs or unusual kernel warnings related to locking. 6) Test kernel updates in staging environments to ensure compatibility and stability before production deployment. These steps go beyond generic advice by focusing on proactive detection, controlled patch deployment, and operational adjustments to reduce exposure.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
Linux
Date Reserved
2024-02-19T14:20:24.211Z
Cisa Enriched
true
Cvss Version
null
State
PUBLISHED

Threat ID: 682d9829c4522896dcbe317f

Added to database: 5/21/2025, 9:08:57 AM

Last enriched: 6/29/2025, 2:39:30 PM

Last updated: 6/29/2025, 3:55:27 PM

Views: 3

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats