# CVE-2021-46989: hfsplus: prevent corruption in shrinking truncate

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

- **Severity:** HIGH 7.1
- **CVSS:** 7.1 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: High; 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.24% (percentile 9, 2026-11-26)
- **Published:** 2024-02-28T08:13:15.930Z
- **Modified:** 2026-08-05T08:45:24.640Z

## Who should check

- Anyone running Linux \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< 52dde855663e5db824af51db39b5757d2ef3e28a; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< c451a6bafb5f422197d31536f82116aed132b72c; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< adbd8a2a8cc05d9e501f93e5c95c59307874cc99; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< c477f62db1a0c0ecaa60a29713006ceeeb04b685; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< 97314e45aa1223a42d60256a62c5d9af54baf446; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< c3187cf32216313fb316084efac4dab3a8459b1d
- Anyone running Linux 4.19

## Description

In the Linux kernel, the following vulnerability has been resolved:

hfsplus: prevent corruption in shrinking truncate

I believe there are some issues introduced by commit 31651c607151
("hfsplus: avoid deadlock on file truncation")

HFS+ has extent records which always contains 8 extents.  In case the
first extent record in catalog file gets full, new ones are allocated from
extents overflow file.

In case shrinking truncate happens to middle of an extent record which
locates in extents overflow file, the logic in hfsplus\_file\_truncate() was
changed so that call to hfs\_brec\_remove() is not guarded any more.

Right action would be just freeing the extents that exceed the new size
inside extent record by calling hfsplus\_free\_extents(), and then check if
the whole extent record should be removed.  However since the guard
(blk\_cnt \> start) is now after the call to hfs\_brec\_remove(), this has
unfortunate effect that the last matching extent record is removed
unconditionally.

To reproduce this issue, create a file which has at least 10 extents, and
then perform shrinking truncate into middle of the last extent record, so
that the number of remaining extents is not under or divisible by 8.  This
causes the last extent record (8 extents) to be removed totally instead of
truncating into middle of it.  Thus this causes corruption, and lost data.

Fix for this is simply checking if the new truncated end is below the
start of this extent record, making it safe to remove the full extent
record.  However call to hfs\_brec\_remove() can't be moved to it's previous
place since we're dropping -\>tree\_lock and it can cause a race condition
and the cached info being invalidated possibly corrupting the node data.

Another issue is related to this one.  When entering into the block
(blk\_cnt \> start) we are not holding the -\>tree\_lock.  We break out from
the loop not holding the lock, but hfs\_find\_exit() does unlock it.  Not
sure if it's possible for someone else to take the lock under our feet,
but it can cause hard to debug errors and premature unlocking.  Even if
there's no real risk of it, the locking should still always be kept in
balance.  Thus taking the lock now just before the check.

## Affected and fixed versions

- Linux: \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< 52dde855663e5db824af51db39b5757d2ef3e28a; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< c451a6bafb5f422197d31536f82116aed132b72c; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< adbd8a2a8cc05d9e501f93e5c95c59307874cc99; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< c477f62db1a0c0ecaa60a29713006ceeeb04b685; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< 97314e45aa1223a42d60256a62c5d9af54baf446; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< c3187cf32216313fb316084efac4dab3a8459b1d (cvelist)
- Linux: 4.19 (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-46989. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2021-46989.md
Affected: Linux >= 31651c607151f1034cfb57e5a78678bea54c362b, < 52dde855663e5db824af51db39b5757d2ef3e28a; >= 31651c607151f1034cfb57e5a78678bea54c362b, < c451a6bafb5f422197d31536f82116aed132b72c; >= 31651c607151f1034cfb57e5a78678bea54c362b, < adbd8a2a8cc05d9e501f93e5c95c59307874cc99; >= 31651c607151f1034cfb57e…
Fixed in: Linux 52dde855663e5db824af51db39b5757d2ef3e28a, Linux 97314e45aa1223a42d60256a62c5d9af54baf446

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-46989 being exploited?

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

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

High: CVSS 7.1 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

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

Linux \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< 52dde855663e5db824af51db39b5757d2ef3e28a; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< c451a6bafb5f422197d31536f82116aed132b72c; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< adbd8a2a8cc05d9e501f93e5c95c59307874cc99; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< c477f62db1a0c0ecaa60a29713006ceeeb04b685; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< 97314e45aa1223a42d60256a62c5d9af54baf446; \>= 31651c607151f1034cfb57e5a78678bea54c362b, \< c3187cf32216313fb316084efac4dab3a8459b1d; Linux 4.19.

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

Yes. Fixed in Linux 52dde855663e5db824af51db39b5757d2ef3e28a, Linux 97314e45aa1223a42d60256a62c5d9af54baf446. No fix listed yet: follow the vendor advisory.

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

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/52dde855663e5db824af51db39b5757d2ef3e28a>
- patch: <https://git.kernel.org/stable/c/c451a6bafb5f422197d31536f82116aed132b72c>
- patch: <https://git.kernel.org/stable/c/adbd8a2a8cc05d9e501f93e5c95c59307874cc99>
- patch: <https://git.kernel.org/stable/c/c477f62db1a0c0ecaa60a29713006ceeeb04b685>
- patch: <https://git.kernel.org/stable/c/97314e45aa1223a42d60256a62c5d9af54baf446>
- patch: <https://git.kernel.org/stable/c/c3187cf32216313fb316084efac4dab3a8459b1d>

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

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