cve.bz

CVE-2024-57976 linux linux kernel: Incomplete Cleanup

5.5 mediumEPSS 0.3%Fix available

Medium (5.5) in linux linux kernel. EPSS 0.3% estimated probability of exploitation activity in the next 30 days.

On this page
In the Linux kernel, the following vulnerability has been resolved: btrfs: do proper folio cleanup when cow_file_range() failed [BUG] When testing with COW fixup marked as BUG_ON() (this is involved with the new pin_user_pages*() change, which should not result new out-of-band dirty pages), I hit a crash triggered by the BUG_ON() from hitting COW fixup path. This BUG_ON() happens just after a failed btrfs_run_delalloc_range(): BTRFS error (device dm-2): failed to run delalloc range, root 348 ino 405 folio 65536 submit_bitmap 6-15 start 90112 len 106496: -28 ------------[ cut here ]------------ kernel BUG at fs/btrfs/extent_io.c:1444! Internal error: Oops - BUG: 00000000f2000800 [#1] SMP CPU: 0 UID: 0 PID: 434621 Comm: kworker/u24:8 Tainted: G OE 6.12.0-rc7-custom+ #86 Hardware name: QEMU KVM Virtual Machine, BIOS unknown 2/2/2022 Workqueue: events_unbound btrfs_async_reclaim_data_space [btrfs] pc : extent_writepage_io+0x2d4/0x308 [btrfs] lr : extent_writepage_io+0x2d4/0x308 [btrfs] Call trace: extent_writepage_io+0x2d4/0x308 [btrfs] extent_writepage+0x218/0x330 [btrfs] extent_write_cache_pages+0x1d4/0x4b0 [btrfs] btrfs_writepages+0x94/0x150 [btrfs] do_writepages+0x74/0x190 filemap_fdatawrite_wbc+0x88/0xc8 start_delalloc_inodes+0x180/0x3b0 [btrfs] btrfs_start_delalloc_roots+0x174/0x280 [btrfs] shrink_delalloc+0x114/0x280 [btrfs] flush_space+0x250/0x2f8 [btrfs] btrfs_async_reclaim_data_space+0x180/0x228 [btrfs] process_one_work+0x164/0x408 worker_thread+0x25c/0x388 kthread+0x100/0x118 ret_from_fork+0x10/0x20 Code: aa1403e1 9402f3ef aa1403e0 9402f36f (d4210000) ---[ end trace 0000000000000000 ]--- [CAUSE] That failure is mostly from cow_file_range(), where we can hit -ENOSPC. Although the -ENOSPC is already a bug related to our space reservation code, let's just focus on the error handling. For example, we have the following dirty range [0, 64K) of an inode, with 4K sector size and 4K page size: 0 16K 32K 48K 64K |///////////////////////////////////////| |#######################################| Where |///| means page are still dirty, and |###| means the extent io tree has EXTENT_DELALLOC flag. - Enter extent_writepage() for page 0 - Enter btrfs_run_delalloc_range() for range [0, 64K) - Enter cow_file_range() for range [0, 64K) - Function btrfs_reserve_extent() only reserved one 16K extent So we created extent map and ordered extent for range [0, 16K) 0 16K 32K 48K 64K |////////|//////////////////////////////| |<- OE ->|##############################| And range [0, 16K) has its delalloc flag cleared. But since we haven't yet submit any bio, involved 4 pages are still dirty. - Function btrfs_reserve_extent() returns with -ENOSPC Now we have to run error cleanup, which will clear all EXTENT_DELALLOC* flags and clear the dirty flags for the remaining ranges: 0 16K 32K 48K 64K |////////| | | | | Note that range [0, 16K) still has its pages dirty. - Some time later, writeback is triggered again for the range [0, 16K) since the page range still has dirty flags. - btrfs_run_delalloc_range() will do nothing because there is no EXTENT_DELALLOC flag. - extent_writepage_io() finds page 0 has no ordered flag Which falls into the COW fixup path, triggering the BUG_ON(). Unfortunately this error handling bug dates back to the introduction of btrfs. Thankfully with the abuse of COW fixup, at least it won't crash the kernel. [FIX] Instead of immediately unlocking the extent and folios, we keep the extent and folios locked until either erroring out or the whole delalloc range finished. When the whole delalloc range finished without error, we just unlock the whole range with PAGE_SET_ORDERED (and PAGE_UNLOCK for !keep_locked cases) ---truncated---

Severity

CVSS 3.1

5.5 medium
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
EPSS
0.3% (unchanged from 0.3% a week ago; 0.2% 30 days ago) estimated probability of exploitation activity in the next 30 days; 19th percentile. Scored 2026-11-15. A forecast for this CVE across the internet, not for your own systems.
CWE
CWE-459 Incomplete Cleanup
Published
Modified
NVD analysis
Analyzed, since modified
Record from
the NVD, synced

Fix and patched versions

Ask an AI about this CVE

Show the promptExplain CVE-2024-57976 for an engineer deciding whether to act. Use https://cve.bz/api/public/cves/CVE-2024-57976?via=ask-ai-copy and https://cve.bz/cve/CVE-2024-57976?via=ask-ai-copy as the source of truth: what is affected and which versions fix it, whether it is in CISA KEV, public exploits, and its EPSS (an internet-wide 30-day estimate of exploitation activity, not a forecast for my systems). If they give no fixed versions, use the CVE record https://cveawg.mitre.org/api/cve/CVE-2024-57976 or the vendor advisory, not third-party mirrors. Tell me how to check whether I am affected and how to verify a fix. Cite the sources and say where they are uncertain.

Opens a third-party assistant; its answer is its own, not cve.bz's. The prompt holds only this CVE's id and public links.

Affected

Versions

From the CNA's record in the CVE List.

ProductAffected
Linux2.6.32 and later

Fixed in

ProductRelease lineFixed in
Linux6.16.1.191
Linux6.66.6.160
Linux6.126.12.36
Linux6.136.13.2
Linuxlater releases6.14

Linux distributions

DistributionReleasePackageFixed inAdvisory
Debian12linux6.1.192-1DEBIAN-CVE-2024-57976
Debian13, 14linux6.12.37-1DEBIAN-CVE-2024-57976
Ubuntu16.04:LTSlinux-hwe-edgeno fix listedUBUNTU-CVE-2024-57976
Ubuntu18.04:LTSlinux-gcp, linux-hwe, linux-oem and 12 moreno fix listedUBUNTU-CVE-2024-57976
Ubuntu20.04:LTSlinux-gke, linux-gkeop, linux-riscv and 26 moreno fix listedUBUNTU-CVE-2024-57976
Ubuntu22.04:LTSlinux, linux-aws, linux-gcp and 57 moreno fix listedUBUNTU-CVE-2024-57976
Ubuntu24.04:LTSlinux, linux-aws, linux-gcp and 25 moreno fix listedUBUNTU-CVE-2024-57976
UbuntuNvidia-BlueField:22.04:LTS, Nvidia-BlueField:24.04:LTSlinux-bluefieldno fix listedUBUNTU-CVE-2024-57976
UbuntuPro:14.04:LTSlinux, linux-aws, linux-azure and 1 moreno fix listedUBUNTU-CVE-2024-57976
UbuntuPro:16.04:LTSlinux, linux-aws, linux-gcp and 5 moreno fix listedUBUNTU-CVE-2024-57976
UbuntuPro:18.04:LTSlinux, linux-aws, linux-kvm and 10 moreno fix listedUBUNTU-CVE-2024-57976
UbuntuPro:20.04:LTSlinux, linux-aws, linux-gcp and 19 moreno fix listedUBUNTU-CVE-2024-57976
UbuntuPro:FIPS-preview:22.04:LTS, Pro:FIPS-updates:18.04:LTS, Pro:FIPS-updates:20.04:LTS and 4 morelinux-fips, linux-aws-fips, linux-gcp-fips and 1 moreno fix listedUBUNTU-CVE-2024-57976
UbuntuPro:FIPS-updates:16.04:LTS, Pro:FIPS:16.04:LTSlinux-fipsno fix listedUBUNTU-CVE-2024-57976
2 more for Ubuntu in the JSON and on Ubuntu's page.
Azure Linux2kernelno fix listedAZL-68754
Azure Linux3kernelno fix listedAZL-62627
Alpaquita23linux-lts6.1.191-r0BELL-CVE-2024-57976
Alpaquita25linux-lts6.12.41-r0BELL-CVE-2024-57976
Alpaquitastreamlinux-lts6.18.35-r1BELL-CVE-2024-57976

From the distributions' data via OSV.dev: the Debian Security Tracker; Ubuntu Security Notices © Canonical Ltd., CC BY-SA 4.0; Microsoft's Azure Linux vulnerability data, MIT; BellSoft's OSV database, MIT. Modified: reformatted and linked to CVE records. Credits. On the distributions' own pages: Debian · Ubuntu · Alpaquita.

Red Hat

Red Hat rates this Moderate.

ProductPackageStateAdvisory
Red Hat Enterprise Linux 10kernelNot affected
Red Hat Enterprise Linux 6kernelOut of support scope
Red Hat Enterprise Linux 7kernelOut of support scope
Red Hat Enterprise Linux 7kernel-rtOut of support scope
Red Hat Enterprise Linux 8kernelNot affected
Red Hat Enterprise Linux 8kernel-rtNot affected
Red Hat Enterprise Linux 9kernelNot affected
Red Hat Enterprise Linux 9kernel-rtNot affected

Contains Red Hat Security Data © Red Hat, Inc., licensed under CC BY 4.0. Source: https://access.redhat.com/security/data. Modified: reformatted. Red Hat's page for CVE-2024-57976.

References

Check your stackJSON