# CVE-2025-68358: btrfs: fix racy bitfield write in btrfs\_clear\_space\_info\_full()

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

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; 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.21% (percentile 7, 2026-11-26)
- **Published:** 2025-12-24T10:32:47.692Z
- **Modified:** 2026-06-17T09:58:59.683Z

## Who should check

- Anyone running Linux \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< b0bb67385480a3aa4c54b139e4f371ddd06b5150; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< 55835646da78e83e7ad06abd741ca8fd8c0b0ea7; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< d4a81b8ec639895999275ea2472c69825cd67ea4; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< db4ae18e1b31e0421fb5312e56aefa382bbc6ece; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< 6f442808a86eef847ee10afa9e6459494ed85bb3; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< 742b90eaf394f0018352c0e10dc89763b2dd5267; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< 38e818718c5e04961eea0fa8feff3f100ce40408
- Anyone running Linux 4.8

## Description

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

btrfs: fix racy bitfield write in btrfs\_clear\_space\_info\_full()

From the memory-barriers.txt document regarding memory barrier ordering
guarantees:

 (\*) These guarantees do not apply to bitfields, because compilers often
     generate code to modify these using non-atomic read-modify-write
     sequences.  Do not attempt to use bitfields to synchronize parallel
     algorithms.

 (\*) Even in cases where bitfields are protected by locks, all fields
     in a given bitfield must be protected by one lock.  If two fields
     in a given bitfield are protected by different locks, the compiler's
     non-atomic read-modify-write sequences can cause an update to one
     field to corrupt the value of an adjacent field.

btrfs\_space\_info has a bitfield sharing an underlying word consisting of
the fields full, chunk\_alloc, and flush:

struct btrfs\_space\_info {
        struct btrfs\_fs\_info \*     fs\_info;              /\*     0     8 \*/
        struct btrfs\_space\_info \*  parent;               /\*     8     8 \*/
        ...
        int                        clamp;                /\*   172     4 \*/
        unsigned int               full:1;               /\*   176: 0  4 \*/
        unsigned int               chunk\_alloc:1;        /\*   176: 1  4 \*/
        unsigned int               flush:1;              /\*   176: 2  4 \*/
        ...

Therefore, to be safe from parallel read-modify-writes losing a write to
one of the bitfield members protected by a lock, all writes to all the
bitfields must use the lock. They almost universally do, except for
btrfs\_clear\_space\_info\_full() which iterates over the space\_infos and
writes out found-\>full = 0 without a lock.

Imagine that we have one thread completing a transaction in which we
finished deleting a block\_group and are thus calling
btrfs\_clear\_space\_info\_full() while simultaneously the data reclaim
ticket infrastructure is running do\_async\_reclaim\_data\_space():

          T1                                             T2
btrfs\_commit\_transaction
  btrfs\_clear\_space\_info\_full
  data\_sinfo-\>full = 0
  READ: full:0, chunk\_alloc:0, flush:1
                                              do\_async\_reclaim\_data\_space(data\_sinfo)
                                              spin\_lock(&space\_info-\>lock);
                                              if(list\_empty(tickets))
                                                space\_info-\>flush = 0;
                                                READ: full: 0, chunk\_alloc:0, flush:1
                                                MOD/WRITE: full: 0, chunk\_alloc:0, flush:0
                                                spin\_unlock(&space\_info-\>lock);
                                                return;
  MOD/WRITE: full:0, chunk\_alloc:0, flush:1

and now data\_sinfo-\>flush is 1 but the reclaim worker has exited. This
breaks the invariant that flush is 0 iff there is no work queued or
running. Once this invariant is violated, future allocations that go
into \_\_reserve\_bytes() will add tickets to space\_info-\>tickets but will
see space\_info-\>flush is set to 1 and not queue the work. After this,
they will block forever on the resulting ticket, as it is now impossible
to kick the worker again.

I also confirmed by looking at the assembly of the affected kernel that
it is doing RMW operations. For example, to set the flush (3rd) bit to 0,
the assembly is:
  andb    $0xfb,0x60(%rbx)
and similarly for setting the full (1st) bit to 0:
  andb    $0xfe,-0x20(%rax)

So I think this is really a bug on practical systems.  I have observed
a number of systems in this exact state, but am currently unable to
reproduce it.

Rather than leaving this footgun lying around for the future, take
advantage of the fact that there is room in the struct anyway, and that
it is already quite large and simply change the three bitfield members to
bools. This avoids writes to space\_info-\>full having any effect on
---truncated---

## Affected and fixed versions

- Linux: \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< b0bb67385480a3aa4c54b139e4f371ddd06b5150; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< 55835646da78e83e7ad06abd741ca8fd8c0b0ea7; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< d4a81b8ec639895999275ea2472c69825cd67ea4; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< db4ae18e1b31e0421fb5312e56aefa382bbc6ece; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< 6f442808a86eef847ee10afa9e6459494ed85bb3; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< 742b90eaf394f0018352c0e10dc89763b2dd5267; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< 38e818718c5e04961eea0fa8feff3f100ce40408 (cvelist)
- Linux: 4.8 (cvelist)

## Mitigation

- Upgrade Linux to 38e818718c5e04961eea0fa8feff3f100ce40408 or later.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2025-68358.md
Affected: Linux >= 957780eb2788d8c218d539e19a85653f51a96dc1, < b0bb67385480a3aa4c54b139e4f371ddd06b5150; >= 957780eb2788d8c218d539e19a85653f51a96dc1, < 55835646da78e83e7ad06abd741ca8fd8c0b0ea7; >= 957780eb2788d8c218d539e19a85653f51a96dc1, < d4a81b8ec639895999275ea2472c69825cd67ea4; >= 957780eb2788d8c218d539e…
Fixed in: Linux 55835646da78e83e7ad06abd741ca8fd8c0b0ea7, Linux 6f442808a86eef847ee10afa9e6459494ed85bb3, Linux 742b90eaf394f0018352c0e10dc89763b2dd5267, Linux 38e818718c5e04961eea0fa8feff3f100ce40408

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-2025-68358 being exploited?

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

### How serious is CVE-2025-68358?

Medium: CVSS 5.5 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2025-68358?

Linux \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< b0bb67385480a3aa4c54b139e4f371ddd06b5150; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< 55835646da78e83e7ad06abd741ca8fd8c0b0ea7; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< d4a81b8ec639895999275ea2472c69825cd67ea4; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< db4ae18e1b31e0421fb5312e56aefa382bbc6ece; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< 6f442808a86eef847ee10afa9e6459494ed85bb3; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< 742b90eaf394f0018352c0e10dc89763b2dd5267; \>= 957780eb2788d8c218d539e19a85653f51a96dc1, \< 38e818718c5e04961eea0fa8feff3f100ce40408; Linux 4.8.

### Is there a fix for CVE-2025-68358?

Yes. Fixed in Linux 55835646da78e83e7ad06abd741ca8fd8c0b0ea7, Linux 6f442808a86eef847ee10afa9e6459494ed85bb3, Linux 742b90eaf394f0018352c0e10dc89763b2dd5267, Linux 38e818718c5e04961eea0fa8feff3f100ce40408. Upgrade Linux to 38e818718c5e04961eea0fa8feff3f100ce40408 or later.

### How do I check if I'm affected by CVE-2025-68358?

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/b0bb67385480a3aa4c54b139e4f371ddd06b5150>
- patch: <https://git.kernel.org/stable/c/55835646da78e83e7ad06abd741ca8fd8c0b0ea7>
- patch: <https://git.kernel.org/stable/c/d4a81b8ec639895999275ea2472c69825cd67ea4>
- patch: <https://git.kernel.org/stable/c/db4ae18e1b31e0421fb5312e56aefa382bbc6ece>
- patch: <https://git.kernel.org/stable/c/6f442808a86eef847ee10afa9e6459494ed85bb3>
- patch: <https://git.kernel.org/stable/c/742b90eaf394f0018352c0e10dc89763b2dd5267>
- patch: <https://git.kernel.org/stable/c/38e818718c5e04961eea0fa8feff3f100ce40408>

## 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-2025-68358>

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