CVE-2021-46989
hfsplus: prevent corruption in shrinking truncate
Check your servers for CVE-2021-46989
The Vulnpocalypse collector sends the package list of each Linux server and of its container images once a day. Vulnpocalypse shows every server where CVE-2021-46989 affects the running kernel, with the command that installs the fix. The free plan covers one server and one domain and does not need a credit card.
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.
Severity (CVSS)
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H
- Attack vector
- local: the attacker needs local access, or a user has to open a prepared file
- Attack complexity
- low: an attack works without special conditions
- Privileges required
- low: the attacker needs an ordinary user account
- User interaction
- none: nobody has to click or open anything
- Scope
- unchanged: the damage stays inside the vulnerable component
- Impact
- confidentiality none, integrity high, availability high: what an attacker can read (confidentiality), change (integrity) or stop (availability)
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
- Attack vector
- local: the attacker needs local access, or a user has to open a prepared file
- Attack complexity
- low: an attack works without special conditions
- Privileges required
- low: the attacker needs an ordinary user account
- User interaction
- none: nobody has to click or open anything
- Scope
- unchanged: the damage stays inside the vulnerable component
- Impact
- confidentiality none, integrity none, availability high: what an attacker can read (confidentiality), change (integrity) or stop (availability)
Exploitation
EPSS 0.24%: the probability of exploitation activity in the next 30 days, from the EPSS model of FIRST. The score is higher than 16.5% of all scored CVEs. Scores of 1 Dec 2026.
The assessment of CISA (SSVC, 28 Feb 2024):
- Exploitation
- none: CISA did not find evidence of exploitation or a public proof of concept
- Automatable
- no: each attack takes manual steps
- Technical impact
- partial: limited control or limited data
Affected products
As the CNA lists them.
| Product | Versions |
|---|---|
| Linux |
affected from 31651c607151f1034cfb57e5a78678bea54c362b, before 52dde855663e5db824af51db39b5757d2ef3e28a affected from 31651c607151f1034cfb57e5a78678bea54c362b, before c451a6bafb5f422197d31536f82116aed132b72c affected from 31651c607151f1034cfb57e5a78678bea54c362b, before adbd8a2a8cc05d9e501f93e5c95c59307874cc99 affected from 31651c607151f1034cfb57e5a78678bea54c362b, before c477f62db1a0c0ecaa60a29713006ceeeb04b685 affected from 31651c607151f1034cfb57e5a78678bea54c362b, before 97314e45aa1223a42d60256a62c5d9af54baf446 affected from 31651c607151f1034cfb57e5a78678bea54c362b, before c3187cf32216313fb316084efac4dab3a8459b1d
Other versions: unaffected
|
| Linux |
affected 4.19 unaffected before 4.19 unaffected from 4.19.191 up to and including 4.19.* unaffected from 5.4.120 up to and including 5.4.* unaffected from 5.10.38 up to and including 5.10.* unaffected from 5.11.22 up to and including 5.11.* unaffected from 5.12.5 up to and including 5.12.* unaffected 5.13 and later
Other versions: affected
|
Is my server affected?
This CVE is in the Linux kernel. Compare the running kernel with the fixed kernel version of your distribution, and reboot after a kernel update:
uname -r
# Debian, Ubuntu: does the changelog of the running kernel name the CVE?
zgrep -l CVE-2021-46989 /usr/share/doc/linux-image-$(uname -r)/changelog.Debian.gz
# RHEL, Rocky, Alma
rpm -q --changelog kernel | grep CVE-2021-46989
With Trivy, on the host and for a container image. When a package is affected, it prints the installed and the fixed version:
trivy rootfs --scanners vuln / | grep CVE-2021-46989
trivy image --scanners vuln IMAGE | grep CVE-2021-46989
Vulnpocalypse makes this comparison every day for the package lists of your servers and container images, including language packages (npm, PyPI, Go, Maven and others), and sends the command that installs the fix. Start free with one server and one domain or read how to install the collector.
References
Other references
- https://git.kernel.org/stable/c/52dde855663e5db824af51db39b5757d2ef3e28a git.kernel.org
- https://git.kernel.org/stable/c/c451a6bafb5f422197d31536f82116aed132b72c git.kernel.org
- https://git.kernel.org/stable/c/adbd8a2a8cc05d9e501f93e5c95c59307874cc99 git.kernel.org
- https://git.kernel.org/stable/c/c477f62db1a0c0ecaa60a29713006ceeeb04b685 git.kernel.org
- https://git.kernel.org/stable/c/97314e45aa1223a42d60256a62c5d9af54baf446 git.kernel.org
- https://git.kernel.org/stable/c/c3187cf32216313fb316084efac4dab3a8459b1d git.kernel.org
Source: the record CVE-2021-46989 of the CVE List (CVE Program), CVE Terms of Use; the CISA KEV catalog and the CISA ADP container; EPSS of FIRST. The text of the record is shown as published. Data sources and licences.
Vulnpocalypse