# CVE-2021-46982: f2fs: compress: fix race condition of overwrite vs truncate

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 4.7
- **CVSS:** 4.7 (v3.1, NVD) `CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: High; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.18% (percentile 4, 2026-11-26)
- **CWE:** CWE-362
- **Published:** 2024-02-28T08:13:11.585Z
- **Modified:** 2026-06-17T04:16:04.217Z

## Who should check

- Anyone running Linux \>= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, \< 5639b73fd3bc6fc8ca72e3a9ac15aacaabd7ebff; \>= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, \< 64acb100fe3beb5d20184d0ae3307235bd3555c4; \>= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, \< 936158b15e2648253afb824d252c910c496d34b5; \>= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, \< a949dc5f2c5cfe0c910b664650f45371254c0744
- Anyone running Linux 5.6

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

## Affected and fixed versions

- Linux: \>= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, \< 5639b73fd3bc6fc8ca72e3a9ac15aacaabd7ebff; \>= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, \< 64acb100fe3beb5d20184d0ae3307235bd3555c4; \>= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, \< 936158b15e2648253afb824d252c910c496d34b5; \>= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, \< a949dc5f2c5cfe0c910b664650f45371254c0744 (cvelist)
- Linux: 5.6 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2021-46982. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2021-46982.md
Affected: Linux >= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, < 5639b73fd3bc6fc8ca72e3a9ac15aacaabd7ebff; >= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, < 64acb100fe3beb5d20184d0ae3307235bd3555c4; >= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, < 936158b15e2648253afb824d252c910c496d34b5; >= 4c8ff7095bef64fc47e996a…
Fixed in: Linux 5639b73fd3bc6fc8ca72e3a9ac15aacaabd7ebff, Linux 64acb100fe3beb5d20184d0ae3307235bd3555c4, Linux 936158b15e2648253afb824d252c910c496d34b5

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2021-46982 being exploited?

There is no confirmed exploitation: CVE-2021-46982 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.18% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2021-46982?

Medium: CVSS 4.7 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed). The attack needs conditions outside the attacker's control, which makes it harder.

### Which versions are affected by CVE-2021-46982?

Linux \>= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, \< 5639b73fd3bc6fc8ca72e3a9ac15aacaabd7ebff; \>= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, \< 64acb100fe3beb5d20184d0ae3307235bd3555c4; \>= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, \< 936158b15e2648253afb824d252c910c496d34b5; \>= 4c8ff7095bef64fc47e996a938f7d57f9e077da3, \< a949dc5f2c5cfe0c910b664650f45371254c0744; Linux 5.6.

### Is there a fix for CVE-2021-46982?

Yes. Fixed in Linux 5639b73fd3bc6fc8ca72e3a9ac15aacaabd7ebff, Linux 64acb100fe3beb5d20184d0ae3307235bd3555c4, Linux 936158b15e2648253afb824d252c910c496d34b5. No fix listed yet: follow the vendor advisory.

### How do I check if I'm affected by CVE-2021-46982?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/5639b73fd3bc6fc8ca72e3a9ac15aacaabd7ebff>
- patch: <https://git.kernel.org/stable/c/64acb100fe3beb5d20184d0ae3307235bd3555c4>
- patch: <https://git.kernel.org/stable/c/936158b15e2648253afb824d252c910c496d34b5>
- patch: <https://git.kernel.org/stable/c/a949dc5f2c5cfe0c910b664650f45371254c0744>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2021-46982>

HTML: <https://flawdb.com/CVE-2021-46982> · JSON: <https://flawdb.com/api/v1/entries/CVE-2021-46982>
