Skip to main content

CVE-2023-52896: Vulnerability in Linux Linux

Medium
VulnerabilityCVE-2023-52896cvecve-2023-52896
Published: Wed Aug 21 2024 (08/21/2024, 06:10:36 UTC)
Source: CVE
Vendor/Project: Linux
Product: Linux

Description

In the Linux kernel, the following vulnerability has been resolved: btrfs: fix race between quota rescan and disable leading to NULL pointer deref If we have one task trying to start the quota rescan worker while another one is trying to disable quotas, we can end up hitting a race that results in the quota rescan worker doing a NULL pointer dereference. The steps for this are the following: 1) Quotas are enabled; 2) Task A calls the quota rescan ioctl and enters btrfs_qgroup_rescan(). It calls qgroup_rescan_init() which returns 0 (success) and then joins a transaction and commits it; 3) Task B calls the quota disable ioctl and enters btrfs_quota_disable(). It clears the bit BTRFS_FS_QUOTA_ENABLED from fs_info->flags and calls btrfs_qgroup_wait_for_completion(), which returns immediately since the rescan worker is not yet running. Then it starts a transaction and locks fs_info->qgroup_ioctl_lock; 4) Task A queues the rescan worker, by calling btrfs_queue_work(); 5) The rescan worker starts, and calls rescan_should_stop() at the start of its while loop, which results in 0 iterations of the loop, since the flag BTRFS_FS_QUOTA_ENABLED was cleared from fs_info->flags by task B at step 3); 6) Task B sets fs_info->quota_root to NULL; 7) The rescan worker tries to start a transaction and uses fs_info->quota_root as the root argument for btrfs_start_transaction(). This results in a NULL pointer dereference down the call chain of btrfs_start_transaction(). The stack trace is something like the one reported in Link tag below: general protection fault, probably for non-canonical address 0xdffffc0000000041: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000208-0x000000000000020f] CPU: 1 PID: 34 Comm: kworker/u4:2 Not tainted 6.1.0-syzkaller-13872-gb6bb9676f216 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Workqueue: btrfs-qgroup-rescan btrfs_work_helper RIP: 0010:start_transaction+0x48/0x10f0 fs/btrfs/transaction.c:564 Code: 48 89 fb 48 (...) RSP: 0018:ffffc90000ab7ab0 EFLAGS: 00010206 RAX: 0000000000000041 RBX: 0000000000000208 RCX: ffff88801779ba80 RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000 RBP: dffffc0000000000 R08: 0000000000000001 R09: fffff52000156f5d R10: fffff52000156f5d R11: 1ffff92000156f5c R12: 0000000000000000 R13: 0000000000000001 R14: 0000000000000001 R15: 0000000000000003 FS: 0000000000000000(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f2bea75b718 CR3: 000000001d0cc000 CR4: 00000000003506e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> btrfs_qgroup_rescan_worker+0x3bb/0x6a0 fs/btrfs/qgroup.c:3402 btrfs_work_helper+0x312/0x850 fs/btrfs/async-thread.c:280 process_one_work+0x877/0xdb0 kernel/workqueue.c:2289 worker_thread+0xb14/0x1330 kernel/workqueue.c:2436 kthread+0x266/0x300 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 </TASK> Modules linked in: So fix this by having the rescan worker function not attempt to start a transaction if it didn't do any rescan work.

AI-Powered Analysis

AILast updated: 06/28/2025, 01:42:08 UTC

Technical Analysis

CVE-2023-52896 is a race condition vulnerability in the Btrfs (B-tree file system) quota management subsystem of the Linux kernel. The flaw arises when two concurrent tasks interact with quota operations: one task initiates a quota rescan worker via an ioctl call, while another disables quotas simultaneously. Specifically, the race occurs between starting the quota rescan worker and disabling quotas, leading to a NULL pointer dereference. The sequence involves Task A starting a quota rescan and joining a transaction successfully, while Task B disables quotas by clearing the quota-enabled flag and setting the quota root pointer to NULL. The rescan worker, upon starting, checks the quota-enabled flag and exits its loop without performing any rescan work but subsequently attempts to start a transaction using the now NULL quota root pointer. This results in a NULL pointer dereference and a kernel crash (general protection fault), potentially causing a denial of service (DoS) on affected systems. The issue is rooted in improper synchronization and lack of atomicity between quota rescan and disable operations. The vulnerability affects multiple Linux kernel versions as identified by specific commit hashes. The fix involves modifying the rescan worker to avoid starting a transaction if no rescan work was performed, thus preventing the NULL pointer dereference. No known exploits are reported in the wild as of the publication date.

Potential Impact

For European organizations relying on Linux systems with Btrfs file systems and quota management enabled, this vulnerability poses a risk of local denial of service. The kernel crash triggered by the NULL pointer dereference can cause system instability, unexpected reboots, or service interruptions. This is particularly impactful for servers, cloud infrastructure, and critical systems where Btrfs is used for storage management. While the vulnerability requires concurrent quota operations (rescan and disable) to trigger, it can be exploited by local users or processes with the ability to invoke quota ioctl calls, potentially including containerized environments or multi-tenant systems. The impact on confidentiality and integrity is limited since the flaw leads primarily to availability disruption rather than privilege escalation or data corruption. However, availability loss in critical infrastructure, such as financial institutions, healthcare providers, or government agencies in Europe, could have significant operational and reputational consequences. The lack of remote exploitability reduces the attack surface but does not eliminate risk in environments where untrusted users have local access.

Mitigation Recommendations

European organizations should prioritize patching Linux kernels to versions that include the fix for CVE-2023-52896. Kernel updates from trusted vendors or distributions should be applied promptly. Additionally, organizations should audit the use of Btrfs quota features and consider disabling quota management if not required, reducing the attack surface. Implementing strict access controls to limit which users or processes can perform quota ioctl operations is critical to prevent unprivileged exploitation. Monitoring kernel logs for signs of quota-related errors or kernel panics can help detect attempted exploitation. For environments using containerization or virtualization, isolating quota management operations and restricting capabilities related to filesystem ioctl calls can further mitigate risk. Finally, organizations should incorporate this vulnerability into their vulnerability management and incident response plans to ensure rapid detection and remediation.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
Linux
Date Reserved
2024-08-21T06:07:11.014Z
Cisa Enriched
true
Cvss Version
null
State
PUBLISHED

Threat ID: 682d9821c4522896dcbdd87d

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

Last enriched: 6/28/2025, 1:42:08 AM

Last updated: 8/14/2025, 11:46:16 AM

Views: 14

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