CVE-2026-64593

Source
https://cve.org/CVERecord?id=CVE-2026-64593
Import Source
https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-64593.json
JSON Data
https://api.osv.dev/v1/vulns/CVE-2026-64593
Downstream
Published
2026-08-06T07:13:49.700Z
Modified
2026-08-08T03:48:18.990954868Z
Summary
btrfs: do not trim a device which is not writeable
Details

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

btrfs: do not trim a device which is not writeable

[BUG] There is a bug report that btrfs/242 can randomly fail with the following NULL pointer dereference:

run fstests btrfs/242 at 2026-06-01 10:25:08 BTRFS: device fsid d4d7f234-487c-4787-88e4-47a8b68c9874 devid 1 transid 9 /dev/sdc (8:32) scanned by mount (122609) BTRFS info (device sdc): first mount of filesystem d4d7f234-487c-4787-88e4-47a8b68c9874 BTRFS info (device sdc): using crc32c checksum algorithm BTRFS warning (device sdc): devid 2 uuid fbe72d72-3272-482d-80fb-ab88ed398192 is missing BTRFS warning (device sdc): devid 2 uuid fbe72d72-3272-482d-80fb-ab88ed398192 is missing BTRFS info (device sdc): allowing degraded mounts BTRFS info (device sdc): turning on async discard BTRFS info (device sdc): enabling free space tree Unable to handle kernel NULL pointer dereference at virtual address 0000000000000018 user pgtable: 4k pages, 48-bit VAs, pgdp=000000013fd6b000 CPU: 4 UID: 0 PID: 122625 Comm: fstrim Not tainted 7.0.10-2-default #1 PREEMPT(full) openSUSE Tumbleweed e9a5f6b24978fba3bf015a992f865837fdfff3dd Hardware name: QEMU KVM Virtual Machine, BIOS edk2-20250812-19.fc42 08/12/2025 pstate: 01400005 (nzcv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--) pc : btrfstrimfs+0x34c/0xa00 [btrfs] lr : btrfstrimfs+0x1f0/0xa00 [btrfs] Call trace: btrfstrimfs+0x34c/0xa00 [btrfs f02c1d570ceea621c69d302ba75dd61868083840] (P) btrfsioctlfitrim+0xe8/0x178 [btrfs f02c1d570ceea621c69d302ba75dd61868083840] btrfs_ioctl+0xdd4/0x2bd8 [btrfs f02c1d570ceea621c69d302ba75dd61868083840] _arm64sysioctl+0xac/0x108 invokesyscall.constprop.0+0x5c/0xd0 el0svccommon.constprop.0+0x40/0xf0 doel0svc+0x24/0x40 el0svc+0x40/0x1d0 el0t64synchandler+0xa0/0xe8 el0t64sync+0x1b0/0x1b8 Code: 17ffff83 f94017e0 f9002be0 f9402ea0 (f9400c00) ---[ end trace 0000000000000000 ]---

Also the reporter is very kind to test the following ASSERT() added to btrfstrimfreeextentsthrottle():

ASSERT(device->bdev,
       "devid=%llu path=%s dev_state=0x%lx\n",
       device->devid, btrfs_dev_name(device), device->dev_state);

And it shows the following output:

assertion failed: device->bdev, in extent-tree.c:6630 (devid=2 path=/dev/sdd dev_state=0x82)

Which means the device->bdev is NULL, and the devstate is BTRFSDEVSTATEINFSMETADATA | BTRFSDEVSTATEITEMFOUND, without BTRFSDEVSTATE_WRITEABLE flag set.

[CAUSE] The pc points to the following call chain:

btrfstrimfs() |- btrfstrimfreeextents() |- btrfstrimfreeextentsthrottle() |- bdevmaxdiscardsectors(device->bdev)

So the NULL pointer dereference is caused by device->bdev being NULL.

This looks impossible by a quick glance, as just before calling btrfstrimfreeextentsthrottle(), we have skipped any device that has BTRFSDEVSTATE_MISSING flag set.

However in this particular case, there is a window where the missing device is later re-scanned, causing btrfs to remove the BTRFSDEVSTATE_MISSING flag:

btrfscontrolioctl() |- btrfsscanonedevice() |- devicelistadd() |- rcuassignpointer(device->name, name); | This updates the missing device's path to the new good path. | |- clearbit(BTRFSDEVSTATEMISSING, &device->devstate) This removes the BTRFSDEVSTATE_MISSING flag.

This allows the missing device to re-appear and clear the BTRFSDEVSTATEMISSING flag. However the device still does not have the BTRFSDEVSTATEWRITEABLE flag set, nor is its bdev pointer updated.

The bdev pointer remains NULL, triggering the crash later.

[FIX] This is a big de-synchronization between BTRFSDEVSTATE_MISSING and device->bdev pointer, and shows a gap in btrfs's re-appearing-device handling.

The proper handling of re-appearing device will need quite some extra work, which is out of the context of this small ---truncated---

Database specific
{
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/64xxx/CVE-2026-64593.json"
}
References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
499f377f49f085ee4aa214c738e948e88626f39b
Fixed
f41ae7e6664f3c4361129728f2c4d5f3ed995251
Fixed
210af872eafa0cf572a84cb303c0f9d2914c1226
Fixed
3d8fa4b828a86b33c60858e58aaab6df273ede05
Fixed
9c894159c5b8adc84072e3af0e55b0473a69564e
Fixed
02c903fc6fc7e16c5d1f22d18784f1208acf43e3
Fixed
7a64521802997257b144e6edfb4e278dbeb972dd
Fixed
b4af31b898a948e29861cb0bae734058f9a49d9b
Fixed
1b1937eb08f51319bf71575484cde2b8c517aedc

Database specific

source
"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-64593.json"

Linux / Kernel

Package

Name
Kernel

Affected ranges

Type
ECOSYSTEM
Events
Introduced
4.3.0
Fixed
5.10.261
Type
ECOSYSTEM
Events
Introduced
5.11.0
Fixed
5.15.212
Type
ECOSYSTEM
Events
Introduced
5.16.0
Fixed
6.1.178
Type
ECOSYSTEM
Events
Introduced
6.2.0
Fixed
6.6.145
Type
ECOSYSTEM
Events
Introduced
6.7.0
Fixed
6.12.96
Type
ECOSYSTEM
Events
Introduced
6.13.0
Fixed
6.18.39
Type
ECOSYSTEM
Events
Introduced
6.19.0
Fixed
7.1.4

Database specific

source
"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-64593.json"