Skip to main content

CVE-2021-46982: Vulnerability in Linux Linux

High
VulnerabilityCVE-2021-46982cvecve-2021-46982
Published: Wed Feb 28 2024 (02/28/2024, 08:13:11 UTC)
Source: CVE
Vendor/Project: Linux
Product: Linux

Description

In the Linux kernel, the following vulnerability has been resolved: f2fs: compress: fix race condition of overwrite vs truncate pos_fsstress testcase complains a panic as belew: ------------[ cut here ]------------ kernel BUG at fs/f2fs/compress.c:1082! invalid opcode: 0000 [#1] SMP PTI CPU: 4 PID: 2753477 Comm: kworker/u16:2 Tainted: G OE 5.12.0-rc1-custom #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 Workqueue: writeback wb_workfn (flush-252:16) RIP: 0010:prepare_compress_overwrite+0x4c0/0x760 [f2fs] Call Trace: f2fs_prepare_compress_overwrite+0x5f/0x80 [f2fs] f2fs_write_cache_pages+0x468/0x8a0 [f2fs] f2fs_write_data_pages+0x2a4/0x2f0 [f2fs] do_writepages+0x38/0xc0 __writeback_single_inode+0x44/0x2a0 writeback_sb_inodes+0x223/0x4d0 __writeback_inodes_wb+0x56/0xf0 wb_writeback+0x1dd/0x290 wb_workfn+0x309/0x500 process_one_work+0x220/0x3c0 worker_thread+0x53/0x420 kthread+0x12f/0x150 ret_from_fork+0x22/0x30 The root cause is truncate() may race with overwrite as below, so that one reference count left in page can not guarantee the page attaching in mapping tree all the time, after truncation, later find_lock_page() may return NULL pointer. - prepare_compress_overwrite - f2fs_pagecache_get_page - unlock_page - f2fs_setattr - truncate_setsize - truncate_inode_page - delete_from_page_cache - find_lock_page Fix this by avoiding referencing updated page.

AI-Powered Analysis

AILast updated: 06/30/2025, 18:40:21 UTC

Technical Analysis

CVE-2021-46982 is a vulnerability identified in the Linux kernel's f2fs (Flash-Friendly File System) compression code. The issue arises from a race condition between the truncate operation and overwrite operations on compressed pages within the f2fs filesystem. Specifically, the vulnerability occurs because the truncate() function can race with an overwrite, leading to a scenario where a page's reference count does not reliably guarantee its presence in the page cache mapping tree. After truncation, a subsequent call to find_lock_page() may return a NULL pointer, which can cause a kernel panic or system crash. The vulnerability was demonstrated by a kernel BUG triggered in the compress.c source file at the function prepare_compress_overwrite. The root cause is that the page cache management does not properly synchronize the lifecycle of pages during concurrent truncate and overwrite operations, causing invalid memory references. The fix involves avoiding referencing pages that have been updated concurrently, ensuring proper synchronization and preventing the race condition. This vulnerability affects Linux kernel versions around 5.12.0-rc1 and potentially other versions using the vulnerable f2fs compression code. No known exploits are reported in the wild, and no CVSS score has been assigned yet. However, the vulnerability can cause kernel panics and denial of service due to system crashes when triggered.

Potential Impact

For European organizations, this vulnerability poses a risk primarily to systems running Linux kernels with the affected f2fs compression code, especially those using f2fs on flash storage devices. The impact is mainly a denial of service (DoS) through kernel panics and system crashes, which can disrupt critical services and operations. Organizations relying on Linux-based servers, embedded devices, or network appliances that use f2fs could experience unexpected downtime or instability. Although there is no evidence of remote code execution or privilege escalation, the denial of service can affect availability and operational continuity. This is particularly significant for sectors with high availability requirements such as finance, healthcare, telecommunications, and critical infrastructure within Europe. Additionally, the complexity of the race condition means it might be triggered under specific workloads involving concurrent file truncation and compression, which could be exploited by local users or processes with write access. The lack of known exploits reduces immediate risk, but the vulnerability should be addressed promptly to prevent potential future exploitation or accidental system failures.

Mitigation Recommendations

To mitigate this vulnerability, European organizations should: 1) Apply the latest Linux kernel patches that address CVE-2021-46982 as soon as they become available from trusted Linux distribution vendors or the Linux kernel mainline. 2) Identify and inventory systems using the f2fs filesystem with compression enabled, prioritizing patching on these systems. 3) Where patching is delayed, consider temporarily disabling f2fs compression features if feasible to avoid triggering the race condition. 4) Implement monitoring for kernel panics and unusual system crashes related to file system operations to detect potential exploitation or accidental triggers. 5) Restrict unprivileged user access to file operations that could induce concurrent truncate and overwrite scenarios on f2fs volumes, reducing the attack surface. 6) Test patches in staging environments to ensure stability and compatibility before deployment in production. 7) Maintain up-to-date backups and disaster recovery plans to minimize operational impact in case of system crashes. These steps go beyond generic advice by focusing on filesystem-specific configurations, monitoring, and access controls tailored to this vulnerability.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
Linux
Date Reserved
2024-02-27T18:42:55.946Z
Cisa Enriched
true
Cvss Version
null
State
PUBLISHED

Threat ID: 682d9834c4522896dcbe999a

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

Last enriched: 6/30/2025, 6:40:21 PM

Last updated: 8/9/2025, 8:33:46 PM

Views: 17

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