CVE-2024-26727

Source
https://cve.org/CVERecord?id=CVE-2024-26727
Import Source
https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-26727.json
JSON Data
https://api.osv.dev/v1/vulns/CVE-2024-26727
Downstream
Related
Published
2024-04-03T14:55:25.805Z
Modified
2026-03-14T12:27:40.975052Z
Summary
btrfs: do not ASSERT() if the newly created subvolume already got read
Details

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

btrfs: do not ASSERT() if the newly created subvolume already got read

[BUG] There is a syzbot crash, triggered by the ASSERT() during subvolume creation:

assertion failed: !anondev, in fs/btrfs/disk-io.c:1319 ------------[ cut here ]------------ kernel BUG at fs/btrfs/disk-io.c:1319! invalid opcode: 0000 [#1] PREEMPT SMP KASAN RIP: 0010:btrfsgetrootref.part.0+0x9aa/0xa60 <TASK> btrfsgetnewfsroot+0xd3/0xf0 createsubvol+0xd02/0x1650 btrfsmksubvol+0xe95/0x12b0 __btrfsioctlsnap_create+0x2f9/0x4f0 btrfsioctlsnapcreate+0x16b/0x200 btrfsioctl+0x35f0/0x5cf0 __x64sysioctl+0x19d/0x210 dosyscall64+0x3f/0xe0 entrySYSCALL64afterhwframe+0x63/0x6b ---[ end trace 0000000000000000 ]---

[CAUSE] During createsubvol(), after inserting root item for the newly created subvolume, we would trigger btrfsgetnewfsroot() to get the btrfsroot of that subvolume.

The idea here is, we have preallocated an anonymous device number for the subvolume, thus we can assign it to the new subvolume.

But there is really nothing preventing things like backref walk to read the new subvolume. If that happens before we call btrfsgetnewfsroot(), the subvolume would be read out, with a new anonymous device number assigned already.

In that case, we would trigger ASSERT(), as we really expect no one to read out that subvolume (which is not yet accessible from the fs). But things like backref walk is still possible to trigger the read on the subvolume.

Thus our assumption on the ASSERT() is not correct in the first place.

[FIX] Fix it by removing the ASSERT(), and just free the @anon_dev, reset it to 0, and continue.

If the subvolume tree is read out by something else, it should have already get a new anon_dev assigned thus we only need to free the preallocated one.

Database specific
{
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/26xxx/CVE-2024-26727.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
2dfb1e43f57dd3aeaa66f7cf05d068db2d4c8788
Fixed
3f5d47eb163bceb1b9e613c9003bae5fefc0046f
Fixed
e31546b0f34af21738c4ceac47d662c00ee6382f
Fixed
66b317a2fc45b2ef66527ee3f8fa08fb5beab88d
Fixed
833775656d447c545133a744a0ed1e189ce61430
Fixed
5a172344bfdabb46458e03708735d7b1a918c468
Fixed
e03ee2fe873eb68c1f9ba5112fee70303ebf9dfb
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
0 Unknown introduced commit / All previous commits are affected
Last affected
917d608fe375041eb7f29befa6a6d7fd3cf32dde

Database specific

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