CVE-2024-42111 Information
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:
And it also pinned it down to commit b5357cb268c4 (trfs: 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.
Reference
https://git.kernel.org/stable/c/ebe5ea02577b2c527958af1b76ac472c7ab53a56 https://git.kernel.org/stable/c/724d8042cef84496ddb4492dc120291f997ae26b
Share on: