Vulnerability · Published Jul 30, 2024 · Assigned by Linux

CVE-2024-42111btrfs: always do the basic checks for btrfs_qgroup_inherit structure

High 7.8

In plain English

A high-severity security flaw in Linux from Linux. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 0.2% (higher than 11% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.

Severity (CVSS 3.1)7.8High
Exploit odds (30 days)0.2%top 88.7% of all CVEs
Exploited in the wildNo reportsCISA SSVC: none
Attack toolingNoneno public tooling known

Official description

In the Linux kernel, the following vulnerability has been resolved: btrfs: always do the basic checks for btrfs_qgroup_inherit structure [BUG] Syzbot reports the following regression detected by KASAN: BUG: KASAN: slab-out-of-bounds in btrfs_qgroup_inherit+0x42e/0x2e20 fs/btrfs/qgroup.c:3277 Read of size 8 at addr ffff88814628ca50 by task syz-executor318/5171 CPU: 0 PID: 5171 Comm: syz-executor318 Not tainted 6.10.0-rc2-syzkaller-00010-g2ab795141095 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/2024 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report+0x143/0x180 mm/kasan/report.c:601 btrfs_qgroup_inherit+0x42e/0x2e20 fs/btrfs/qgroup.c:3277 create_pending_snapshot+0x1359/0x29b0 fs/btrfs/transaction.c:1854 create_pending_snapshots+0x195/0x1d0 fs/btrfs/transaction.c:1922 btrfs_commit_transaction+0xf20/0x3740 fs/btrfs/transaction.c:2382 create_snapshot+0x6a1/0x9e0 fs/btrfs/ioctl.c:875 btrfs_mksubvol+0x58f/0x710 fs/btrfs/ioctl.c:1029 btrfs_mksnapshot+0xb5/0xf0 fs/btrfs/ioctl.c:1075 __btrfs_ioctl_snap_create+0x387/0x4b0 fs/btrfs/ioctl.c:1340 btrfs_ioctl_snap_create_v2+0x1f2/0x3a0 fs/btrfs/ioctl.c:1422 btrfs_ioctl+0x99e/0xc60 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fcbf1992509 RSP: 002b:00007fcbf1928218 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007fcbf1a1f618 RCX: 00007fcbf1992509 RDX: 0000000020000280 RSI: 0000000050009417 RDI: 0000000000000003 RBP: 00007fcbf1a1f610 R08: 00007ffea1298e97 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007fcbf19eb660 R13: 00000000200002b8 R14: 00007fcbf19e60c0 R15: 0030656c69662f2e </TASK> And it also pinned it down to commit b5357cb268c4 ("btrfs: qgroup: do not check qgroup inherit if qgroup is disabled"). [CAUSE] That offending commit skips the whole qgroup inherit check if qgroup is not enabled. But that also skips the very basic checks like num_ref_copies/num_excl_copies and the structure size checks. Meaning if a qgroup enable/disable race is happening at the background, and we pass a btrfs_qgroup_inherit structure when the qgroup is disabled, the check would be completely skipped. Then at the time of transaction commitment, qgroup is re-enabled and btrfs_qgroup_inherit() is going to use the incorrect structure and causing the above KASAN error. [FIX] Make btrfs_qgroup_check_inherit() only skip the source qgroup checks. So that even if invalid btrfs_qgroup_inherit structure is passed in, we can still reject invalid ones no matter if qgroup is enabled or not. Furthermore we do already have an extra safety inside btrfs_qgroup_inherit(), which would just ignore invalid qgroup sources, so even if we only skip the qgroup source check we're still safe.

Affected packages & fixed versions

EcosystemPackageFixed inAdvisory
Debian:13linux6.9.9-1DEBIAN-CVE-2024-42111
Debian:14linux6.9.9-1DEBIAN-CVE-2024-42111
Ubuntu:24.04:LTSlinux6.8.0-48.48UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-allwinner-5.19no fix listedUBUNTU-CVE-2024-42111
Ubuntu:24.04:LTSlinux-aws6.8.0-1018.20UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-aws-5.19no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-aws-6.2no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-aws-6.5no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-aws-6.86.8.0-1018.19~22.04.1UBUNTU-CVE-2024-42111
Ubuntu:24.04:LTSlinux-azure6.8.0-1017.20UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-azure-5.19no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-azure-6.2no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-azure-6.5no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-azure-6.86.8.0-1017.20~22.04.1UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-azure-fde-5.19no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-azure-fde-6.2no fix listedUBUNTU-CVE-2024-42111
Ubuntu:24.04:LTSlinux-gcp6.8.0-1017.19UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-gcp-5.19no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-gcp-6.2no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-gcp-6.5no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-gcp-6.86.8.0-1017.19~22.04.1UBUNTU-CVE-2024-42111
Ubuntu:24.04:LTSlinux-gke6.8.0-1013.17UBUNTU-CVE-2024-42111
Ubuntu:24.04:LTSlinux-gkeop6.8.0-1002.4UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-hwe-5.19no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-hwe-6.2no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-hwe-6.5no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-hwe-6.86.8.0-48.48~22.04.1UBUNTU-CVE-2024-42111
Ubuntu:24.04:LTSlinux-ibm6.8.0-1015.15UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-intel-iot-realtimeno fix listedUBUNTU-CVE-2024-42111
Ubuntu:24.04:LTSlinux-lowlatency6.8.0-48.48.3UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-lowlatency-hwe-5.19no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.2no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.5no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.86.8.0-48.48.3~22.04.1UBUNTU-CVE-2024-42111
Ubuntu:24.04:LTSlinux-nvidia6.8.0-1017.19UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-nvidia-6.2no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-nvidia-6.86.8.0-1017.19~22.04.1UBUNTU-CVE-2024-42111
Ubuntu:24.04:LTSlinux-nvidia-lowlatency6.8.0-1017.19.1UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-oem-5.17no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-oem-6.0no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-oem-6.1no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-oem-6.5no fix listedUBUNTU-CVE-2024-42111
Ubuntu:24.04:LTSlinux-oem-6.86.8.0-1016.16UBUNTU-CVE-2024-42111
Ubuntu:24.04:LTSlinux-oracle6.8.0-1015.16UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-oracle-6.5no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-oracle-6.86.8.0-1015.15~22.04.1UBUNTU-CVE-2024-42111
Ubuntu:24.04:LTSlinux-raspi6.8.0-1014.16UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-realtimeno fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-riscvno fix listedUBUNTU-CVE-2024-42111
Ubuntu:24.04:LTSlinux-riscv6.8.0-48.48.1UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-riscv-5.19no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-riscv-6.5no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-riscv-6.86.8.0-48.48.1~22.04.2UBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-starfive-5.19no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-starfive-6.2no fix listedUBUNTU-CVE-2024-42111
Ubuntu:22.04:LTSlinux-starfive-6.5no fix listedUBUNTU-CVE-2024-42111

Affected products (as reported)

VendorProductVersions
Linux Linux b5357cb268c41b4e2b7383d2759fc562f5b58c33 – before ebe5ea02577b2c527958af1b76ac472c7ab53a56b5357cb268c41b4e2b7383d2759fc562f5b58c33 – before 724d8042cef84496ddb4492dc120291f997ae26bc839f73a70f312f477225b64020364e108f082316.8.10 – before 6.9
Linux Linux 6.9

References