CVE-2024-38306
published high CVSS 3.1 · 7.8btrfs: protect folio::private when attaching extent buffer folios
Package status and fixes
| Distro / vendor | Release | Package / product | Publisher status | Fixed build | Source |
|---|---|---|---|---|---|
| Linux | — | Linux09e6cef19c9fc0e10547135476865b5272aa0406 to < 952f048eb901881a7cc6f7c1368b53cd386ead7b · 09e6cef19c9fc0e10547135476865b5272aa0406 to < f3a5367c679d31473d3fbb391675055b4792c309 · Other versions: unaffected | Affected | Not stated | Linux |
| Linux | — | Linux6.8 (affected) · 0 to < 6.8 (unaffected · semver) · 6.9.5 through 6.9.* (unaffected · semver) · 6.10 and later (unaffected · original_commit_for_fix) · Other versions: affected | Version-specific | Not stated | Linux |
| Amazon Linux | AL2 | Release evaluation | Not Affected | Not required | Amazon Linux assessment |
| Amazon Linux | AL2023 | Release evaluation | Not Affected | Not required | Amazon Linux assessment |
| Ubuntu | jammy | linux-buildinfo-6.8.0-1013-nvidia | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-buildinfo-6.8.0-1013-nvidia-64k | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-buildinfo-6.8.0-44-lowlatency | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-buildinfo-6.8.0-44-lowlatency-64k | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
Show 96 more entries
| Distro / vendor | Release | Package / product | Publisher status | Fixed build | Source |
|---|---|---|---|---|---|
| Ubuntu | jammy | linux-buildinfo-6.8.0-45-generic | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-buildinfo-6.8.0-45-generic-64k | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-cloud-tools-6.8.0-44-lowlatency | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-cloud-tools-6.8.0-45-generic | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-headers-6.8.0-1013-nvidia | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-headers-6.8.0-1013-nvidia-64k | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-headers-6.8.0-44-lowlatency | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-headers-6.8.0-44-lowlatency-64k | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-headers-6.8.0-45-generic | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-headers-6.8.0-45-generic-64k | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-hwe-6.8 | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-hwe-6.8-cloud-tools-6.8.0-45 | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-hwe-6.8-headers-6.8.0-45 | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-hwe-6.8-tools-6.8.0-45 | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-image-6.8.0-45-generic | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-image-unsigned-6.8.0-1013-nvidia | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-image-unsigned-6.8.0-1013-nvidia-64k | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-image-unsigned-6.8.0-44-lowlatency | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-image-unsigned-6.8.0-44-lowlatency-64k | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-image-unsigned-6.8.0-45-generic | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-image-unsigned-6.8.0-45-generic-64k | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-lowlatency-hwe-6.8 | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-lowlatency-hwe-6.8-cloud-tools-6.8.0-44 | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-lowlatency-hwe-6.8-headers-6.8.0-44 | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-lowlatency-hwe-6.8-lib-rust-6.8.0-44-lowlatency | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-lowlatency-hwe-6.8-tools-6.8.0-44 | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-modules-6.8.0-1013-nvidia | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-modules-6.8.0-1013-nvidia-64k | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-modules-6.8.0-44-lowlatency | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-modules-6.8.0-44-lowlatency-64k | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-modules-6.8.0-45-generic | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-modules-6.8.0-45-generic-64k | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-modules-extra-6.8.0-1013-nvidia | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-modules-extra-6.8.0-45-generic | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-modules-ipu6-6.8.0-45-generic | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-modules-iwlwifi-6.8.0-44-lowlatency | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-modules-iwlwifi-6.8.0-45-generic | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-modules-nvidia-fs-6.8.0-1013-nvidia | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-modules-nvidia-fs-6.8.0-1013-nvidia-64k | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-modules-usbio-6.8.0-45-generic | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-nvidia-6.8 | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-nvidia-6.8-headers-6.8.0-1013 | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-nvidia-6.8-tools-6.8.0-1013 | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-tools-6.8.0-1013-nvidia | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-tools-6.8.0-1013-nvidia-64k | Advisory build | 6.8.0-1013.14~22.04.1 | USN-7005-2 |
| Ubuntu | jammy | linux-tools-6.8.0-44-lowlatency | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-tools-6.8.0-44-lowlatency-64k | Advisory build | 6.8.0-44.44.1~22.04.1 | USN-7008-1 |
| Ubuntu | jammy | linux-tools-6.8.0-45-generic | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | jammy | linux-tools-6.8.0-45-generic-64k | Advisory build | 6.8.0-45.45~22.04.1 | USN-7029-1 |
| Ubuntu | noble | linux | Advisory build | 6.8.0-44.44 | USN-6999-1 |
| Ubuntu | noble | linux-aws | Advisory build | 6.8.0-1015.16 | USN-6999-1 |
| Ubuntu | noble | linux-aws-cloud-tools-6.8.0-1015 | Advisory build | 6.8.0-1015.16 | USN-6999-1 |
| Ubuntu | noble | linux-aws-headers-6.8.0-1015 | Advisory build | 6.8.0-1015.16 | USN-6999-1 |
| Ubuntu | noble | linux-aws-tools-6.8.0-1015 | Advisory build | 6.8.0-1015.16 | USN-6999-1 |
| Ubuntu | noble | linux-azure | Advisory build | 6.8.0-1014.16 | USN-7004-1 |
| Ubuntu | noble | linux-azure-cloud-tools-6.8.0-1014 | Advisory build | 6.8.0-1014.16 | USN-7004-1 |
| Ubuntu | noble | linux-azure-headers-6.8.0-1014 | Advisory build | 6.8.0-1014.16 | USN-7004-1 |
| Ubuntu | noble | linux-azure-tools-6.8.0-1014 | Advisory build | 6.8.0-1014.16 | USN-7004-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-1010-gke | Advisory build | 6.8.0-1010.13 | USN-6999-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-1011-raspi | Advisory build | 6.8.0-1011.12 | USN-6999-2 |
| Ubuntu | noble | linux-buildinfo-6.8.0-1012-ibm | Advisory build | 6.8.0-1012.12 | USN-6999-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-1012-oem | Advisory build | 6.8.0-1012.12 | USN-6999-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-1012-oracle | Advisory build | 6.8.0-1012.12 | USN-6999-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-1012-oracle-64k | Advisory build | 6.8.0-1012.12 | USN-6999-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-1013-nvidia | Advisory build | 6.8.0-1013.14 | USN-7005-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-1013-nvidia-64k | Advisory build | 6.8.0-1013.14 | USN-7005-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-1013-nvidia-lowlatency | Advisory build | 6.8.0-1013.14.1 | USN-7005-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-1013-nvidia-lowlatency-64k | Advisory build | 6.8.0-1013.14.1 | USN-7005-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-1014-azure | Advisory build | 6.8.0-1014.16 | USN-7004-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-1014-gcp | Advisory build | 6.8.0-1014.16 | USN-6999-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-1015-aws | Advisory build | 6.8.0-1015.16 | USN-6999-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-44-generic | Advisory build | 6.8.0-44.44 | USN-6999-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-44-generic-64k | Advisory build | 6.8.0-44.44 | USN-6999-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-44-lowlatency | Advisory build | 6.8.0-44.44.1 | USN-6999-1 |
| Ubuntu | noble | linux-buildinfo-6.8.0-44-lowlatency-64k | Advisory build | 6.8.0-44.44.1 | USN-6999-1 |
| Ubuntu | noble | linux-cloud-tools-6.8.0-1014-azure | Advisory build | 6.8.0-1014.16 | USN-7004-1 |
| Ubuntu | noble | linux-cloud-tools-6.8.0-1015-aws | Advisory build | 6.8.0-1015.16 | USN-6999-1 |
| Ubuntu | noble | linux-cloud-tools-6.8.0-44 | Advisory build | 6.8.0-44.44 | USN-6999-1 |
| Ubuntu | noble | linux-cloud-tools-6.8.0-44-generic | Advisory build | 6.8.0-44.44 | USN-6999-1 |
| Ubuntu | noble | linux-cloud-tools-6.8.0-44-lowlatency | Advisory build | 6.8.0-44.44.1 | USN-6999-1 |
| Ubuntu | noble | linux-cloud-tools-common | Advisory build | 6.8.0-44.44 | USN-6999-1 |
| Ubuntu | noble | linux-gcp | Advisory build | 6.8.0-1014.16 | USN-6999-1 |
| Ubuntu | noble | linux-gcp-headers-6.8.0-1014 | Advisory build | 6.8.0-1014.16 | USN-6999-1 |
| Ubuntu | noble | linux-gcp-tools-6.8.0-1014 | Advisory build | 6.8.0-1014.16 | USN-6999-1 |
| Ubuntu | noble | linux-gke | Advisory build | 6.8.0-1010.13 | USN-6999-1 |
| Ubuntu | noble | linux-gke-headers-6.8.0-1010 | Advisory build | 6.8.0-1010.13 | USN-6999-1 |
| Ubuntu | noble | linux-gke-tools-6.8.0-1010 | Advisory build | 6.8.0-1010.13 | USN-6999-1 |
| Ubuntu | noble | linux-headers-6.8.0-1010-gke | Advisory build | 6.8.0-1010.13 | USN-6999-1 |
| Ubuntu | noble | linux-headers-6.8.0-1011-raspi | Advisory build | 6.8.0-1011.12 | USN-6999-2 |
| Ubuntu | noble | linux-headers-6.8.0-1012-ibm | Advisory build | 6.8.0-1012.12 | USN-6999-1 |
| Ubuntu | noble | linux-headers-6.8.0-1012-oem | Advisory build | 6.8.0-1012.12 | USN-6999-1 |
| Ubuntu | noble | linux-headers-6.8.0-1012-oracle | Advisory build | 6.8.0-1012.12 | USN-6999-1 |
| Ubuntu | noble | linux-headers-6.8.0-1012-oracle-64k | Advisory build | 6.8.0-1012.12 | USN-6999-1 |
| Ubuntu | noble | linux-headers-6.8.0-1013-nvidia | Advisory build | 6.8.0-1013.14 | USN-7005-1 |
| Ubuntu | noble | linux-headers-6.8.0-1013-nvidia-64k | Advisory build | 6.8.0-1013.14 | USN-7005-1 |
| Ubuntu | noble | linux-headers-6.8.0-1013-nvidia-lowlatency | Advisory build | 6.8.0-1013.14.1 | USN-7005-1 |
Package entries are limited to the first 100 builds and 100 linked advisories.
Description
In the Linux kernel, the following vulnerability has been resolved: btrfs: protect folio::private when attaching extent buffer folios [BUG] Since v6.8 there are rare kernel crashes reported by various people, the common factor is bad page status error messages like this: BUG: Bad page state in process kswapd0 pfn:d6e840 page: refcount:0 mapcount:0 mapping:000000007512f4f2 index:0x2796c2c7c pfn:0xd6e840 aops:btree_aops ino:1 flags: 0x17ffffe0000008(uptodate|node=0|zone=2|lastcpupid=0x3fffff) page_type: 0xffffffff() raw: 0017ffffe0000008 dead000000000100 dead000000000122 ffff88826d0be4c0 raw: 00000002796c2c7c 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: non-NULL mapping [CAUSE] Commit 09e6cef19c9f ("btrfs: refactor alloc_extent_buffer() to allocate-then-attach method") changes the sequence when allocating a new extent buffer. Previously we always called grab_extent_buffer() under mapping->i_private_lock, to ensure the safety on modification on folio::private (which is a pointer to extent buffer for regular sectorsize). This can lead to the following race: Thread A is trying to allocate an extent buffer at bytenr X, with 4 4K pages, meanwhile thread B is trying to release the page at X + 4K (the second page of the extent buffer at X). Thread A | Thread B -----------------------------------+------------------------------------- | btree_release_folio() | | This is for the page at X + 4K, | | Not page X. | | alloc_extent_buffer() | |- release_extent_buffer() |- filemap_add_folio() for the | | |- atomic_dec_and_test(eb->refs) | page at bytenr X (the first | | | | page). | | | | Which returned -EEXIST. | | | | | | | |- filemap_lock_folio() | | | | Returned the first page locked. | | | | | | | |- grab_extent_buffer() | | | | |- atomic_inc_not_zero() | | | | | Returned false | | | | |- folio_detach_private() | | |- folio_detach_private() for X | |- folio_test_private() | | |- folio_test_private() | Returned true | | | Returned true |- folio_put() | |- folio_put() Now there are two puts on the same folio at folio X, leading to refcount underflow of the folio X, and eventually causing the BUG_ON() on the page->mapping. The condition is not that easy to hit: - The release must be triggered for the middle page of an eb If the release is on the same first page of an eb, page lock would kick in and prevent the race. - folio_detach_private() has a very small race window It's only between folio_test_private() and folio_clear_private(). That's exactly when mapping->i_private_lock is used to prevent such race, and commit 09e6cef19c9f ("btrfs: refactor alloc_extent_buffer() to allocate-then-attach method") screwed that up. At that time, I thought the page lock would kick in as filemap_release_folio() also requires the page to be locked, but forgot the filemap_release_folio() only locks one page, not all pages of an extent buffer. [FIX] Move all the code requiring i_private_lock into attach_eb_folio_to_filemap(), so that everything is done with proper lock protection. Furthermore to prevent future problems, add an extra lockdep_assert_locked() to ensure we're holding the proper lock. To reproducer that is able to hit the race (takes a few minutes with instrumented code inserting delays to alloc_extent_buffer()): #!/bin/sh drop_caches () { while(true); do echo 3 > /proc/sys/vm/drop_caches echo 1 > /proc/sys/vm/compact_memory done } run_tar () { while(true); do for x in `seq 1 80` ; do tar cf /dev/zero /mnt > /dev/null & done wait done } mkfs.btrfs -f -d single -m single ---truncated---
Related advisories
Vendor advisories explicitly linked to this CVE.
Assessment
CVSS risk assessment and additional context for this vulnerability.
- CVSS version
- 3.1
- Base score
- 7.8 / 10
- Severity
- high
- Provider
- Linux · cna
- Vector string
- CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
- Scenarios
- en: AV:L - The vulnerable code is btrfs metadata page-cache management reached through ordinary filesystem syscalls (stat/readdir/read/open) on a locally mounted btrfs, plus locally-induced memory reclaim. No network protocol handler is involved. AC:L - The attacker controls both sides of the race — concurrent metadata tree walks drive alloc_extent_buffer() while attacker-generated memory pressure drives btree_release_folio() — and can loop indefinitely; the race was hit repeatedly by ordinary users under normal load within days of v6.8. PR:L - Any unprivileged local user with read access to a mounted btrfs can reach alloc_extent_buffer() via btrfs_search_slot()/read_block_for_search(); no capability, mount privilege, or ioctl gate exists on the path. UI:N - No victim action is needed — btrfs is commonly the already-mounted root filesystem, and the attacker triggers both the allocation and the reclaim side entirely on their own. S:U - The refcount underflow and resulting page reuse are confined to the kernel's own memory-management authority; no VM, IOMMU, or hypervisor boundary is crossed. C:H - The folio refcount underflow frees a page that is still live in the btree page cache and still addressed via eb->addr, so the attacker can have that page reallocated to another subsystem and read its contents through btrfs metadata reads — an arbitrary kernel memory disclosure primitive. I:H - The same use-after-free page remains writable through btrfs metadata writeback after being handed to an unrelated allocation, giving a cross-object write primitive suitable for heap grooming and control-flow hijacking. A:H - The bug reliably produces "BUG: Bad page state" and kernel crashes in kswapd and other contexts, as reported by multiple users and syzbot.
Publisher product statements
Version ranges and default statuses as reported by each provider.
| Vendor | Product | Version status | Source |
|---|---|---|---|
| Linux | Linux | 09e6cef19c9fc0e10547135476865b5272aa0406 to < 952f048eb901881a7cc6f7c1368b53cd386ead7b (affected · git)09e6cef19c9fc0e10547135476865b5272aa0406 to < f3a5367c679d31473d3fbb391675055b4792c309 (affected · git)Default: unaffected | Linux · cna |
| Linux | Linux | 6.8 (affected)0 to < 6.8 (unaffected · semver)6.9.5 through 6.9.* (unaffected · semver)6.10 and later (unaffected · original_commit_for_fix)Default: affected | Linux · cna |
Weaknesses
0No weakness assertions.
References
2Provider assertions
3Linux · cna
btrfs: protect folio::private when attaching extent buffer folios
CISA-ADP · adp
CISA ADP Vulnrichment
CVE · adp
CVE Program Container
Provenance
- Schema
- 5.2
- Searchable
- yes
- Content hash
- 7b285f01058e27ec1cb399e58d28fb2924df1da7832e4521d4d42293314ea91c
- Ingested
- 23 Sep 2026, 08:24:48 UTC
- Source record
- Official CVE record