CVE-2026-31666 btrfs: fix incorrect return value after changing leaf in lookup_extent_data_ref()

High 7.8 Published Updated

Incorrect return value in btrfs lookup can cause extent tree corruption by allowing operations on wrong items.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Local or same network only
Victim action needed
Not needed
Fix
Available

What is CVE-2026-31666?

CVE-2026-31666 is a high-severity vulnerability in Linux kernel, published on 24 Apr 2026. It can only be exploited from the same machine or local network, with no action from the victim.

Official description

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

btrfs: fix incorrect return value after changing leaf in lookup_extent_data_ref()

After commit 1618aa3c2e01 ("btrfs: simplify return variables in lookup_extent_data_ref()"), the err and ret variables were merged into a single ret variable. However, when btrfs_next_leaf() returns 0 (success), ret is overwritten from -ENOENT to 0. If the first key in the next leaf does not match (different objectid or type), the function returns 0 instead of -ENOENT, making the caller believe the lookup succeeded when it did not. This can lead to operations on the wrong extent tree item, potentially causing extent tree corruption.

Fix this by returning -ENOENT directly when the key does not match, instead of relying on the ret variable.

Weakness: CWE-754

Which versions are affected by CVE-2026-31666?

It affects 1 product.

Products include Linux kernel.

How do I fix CVE-2026-31666?

Apply the vendor's patch.

Is CVE-2026-31666 being exploited?

There is no known exploitation of CVE-2026-31666 in the wild and no public exploit code.

All Linux kernel vulnerabilities

Sources

Also known as BELL-CVE-2026-31666, DEBIAN-CVE-2026-31666, GHSA-7wrc-m37g-996x, ROOT-OS-DEBIAN-13-CVE-2026-31666, UBUNTU-CVE-2026-31666.

Is CVE-2026-31666 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free