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

Published Jul 30, 2024
·
Updated

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

btrfs: always do the basic checks for btrfsqgroupinherit structure

[BUG] Syzbot reports the following regression detected by KASAN:

BUG: KASAN: slab-out-of-bounds in btrfsqgroupinherit+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> dumpstack lib/dumpstack.c:88 [inline] dumpstacklvl+0x241/0x360 lib/dumpstack.c:114 printaddressdescription mm/kasan/report.c:377 [inline] printreport+0x169/0x550 mm/kasan/report.c:488 kasanreport+0x143/0x180 mm/kasan/report.c:601 btrfsqgroupinherit+0x42e/0x2e20 fs/btrfs/qgroup.c:3277 creatependingsnapshot+0x1359/0x29b0 fs/btrfs/transaction.c:1854 creatependingsnapshots+0x195/0x1d0 fs/btrfs/transaction.c:1922 btrfscommittransaction+0xf20/0x3740 fs/btrfs/transaction.c:2382 createsnapshot+0x6a1/0x9e0 fs/btrfs/ioctl.c:875 btrfsmksubvol+0x58f/0x710 fs/btrfs/ioctl.c:1029 btrfsmksnapshot+0xb5/0xf0 fs/btrfs/ioctl.c:1075 btrfsioctlsnapcreate+0x387/0x4b0 fs/btrfs/ioctl.c:1340 btrfsioctlsnapcreatev2+0x1f2/0x3a0 fs/btrfs/ioctl.c:1422 btrfsioctl+0x99e/0xc60 vfsioctl fs/ioctl.c:51 [inline] dosysioctl fs/ioctl.c:907 [inline] sesysioctl+0xfc/0x170 fs/ioctl.c:893 dosyscallx64 arch/x86/entry/common.c:52 [inline] dosyscall64+0xf3/0x230 arch/x86/entry/common.c:83 entrySYSCALL64afterhwframe+0x77/0x7f RIP: 0033:0x7fcbf1992509 RSP: 002b:00007fcbf1928218 EFLAGS: 00000246 ORIGRAX: 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 numrefcopies/numexclcopies and the structure size checks.

Meaning if a qgroup enable/disable race is happening at the background, and we pass a btrfsqgroupinherit structure when the qgroup is disabled, the check would be completely skipped.

Then at the time of transaction commitment, qgroup is re-enabled and btrfsqgroupinherit() is going to use the incorrect structure and causing the above KASAN error.

[FIX] Make btrfsqgroupcheckinherit() only skip the source qgroup checks. So that even if invalid btrfsqgroupinherit 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 btrfsqgroupinherit(), which would just ignore invalid qgroup sources, so even if we only skip the qgroup source check we're still safe.

Affected Software

10 affected componentsFixes available
debian/linux
5.10.223-15.10.234-16.1.129-16.1.135-16.12.22-16.12.25-1
Linux Linux kernel>=6.8.10<6.9
Linux Linux kernel>=6.9.1<6.9.9
Linux Linux kernel=6.9
Linux Linux kernel=6.10-rc1
Linux Linux kernel=6.10-rc2
Linux Linux kernel=6.10-rc3
Linux Linux kernel=6.10-rc4
Linux Linux kernel=6.10-rc5
Linux Linux kernel=6.10-rc6

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade debian/linux to a version that resolves this vulnerability.

    Fixed in 5.10.223-1Fixed in 5.10.234-1Fixed in 6.1.129-1Fixed in 6.1.135-1Fixed in 6.12.22-1Fixed in 6.12.25-1
  2. Configuration

    Change btrfs_qgroup_check_inherit() so that it does not skip the entire btrfs_qgroup_inherit validation when qgroup is disabled. Instead, when qgroup is disabled, skip only the source qgroup checks while still performing the basic checks on the btrfs_qgroup_inherit structure so invalid structures are rejected even during enable/disable races.

    Linux kernel btrfs (qgroup) btrfs_qgroup_check_inherit() logic = Only skip the source qgroup checks; always do the basic checks for the btrfs_qgroup_inherit structure (including num_ref_copies/num_excl_copies and structure size checks)

Event History

Jul 30, 2024
CVE Published
via MITRE·07:46 AM
Data Sourced
via MITRE·07:46 AM
DescriptionSeverity
Data Sourced
via NVD·08:15 AM
Description
Data Sourced
via NVD·08:15 AM
RemedySeverityWeaknessAffected Software
Dec 15, 2024
Data Sourced
via Ubuntu·12:31 PM
RemedyDescriptionSeverityAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-42111?

CVE-2024-42111 has been classified as a high severity vulnerability due to potential impacts on system stability.

2

How do I fix CVE-2024-42111?

To resolve CVE-2024-42111, update to the patched versions of the Linux kernel, specifically 5.10.223-1, 5.10.226-1, 6.1.119-1, 6.1.123-1, 6.12.10-1, or 6.12.11-1.

3

What are the potential impacts of CVE-2024-42111?

Exploitation of CVE-2024-42111 could lead to a slab-out-of-bounds access issue, resulting in potential data corruption or system crashes.

4

Which software is affected by CVE-2024-42111?

CVE-2024-42111 affects specific versions of the Linux kernel, including several versions from Debian and Ubuntu.

5

Is CVE-2024-42111 related to KASAN?

Yes, CVE-2024-42111 was reported due to a regression detected by KASAN, indicating a memory safety issue with btrfs_qgroup_inherit.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203