CVE-2024-40955: ext4: fix slab-out-of-bounds in ext4_mb_find_good_group_avg_frag_lists()

Published Jul 12, 2024
·
Updated

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

ext4: fix slab-out-of-bounds in ext4mbfindgoodgroupavgfraglists()

We can trigger a slab-out-of-bounds with the following commands:

mkfs.ext4 -F /dev/$disk 10G mount /dev/$disk /tmp/test echo 2147483647 > /sys/fs/ext4/$disk/mbgroupprealloc echo test > /tmp/test/file && sync

================================================================== BUG: KASAN: slab-out-of-bounds in ext4mbfindgoodgroupavgfraglists+0x8a/0x200 [ext4] Read of size 8 at addr ffff888121b9d0f0 by task kworker/u2:0/11 CPU: 0 PID: 11 Comm: kworker/u2:0 Tainted: GL 6.7.0-next-20240118 #521 Call Trace: dumpstacklvl+0x2c/0x50 kasanreport+0xb6/0xf0 ext4mbfindgoodgroupavgfraglists+0x8a/0x200 [ext4] ext4mbregularallocator+0x19e9/0x2370 [ext4] ext4mbnewblocks+0x88a/0x1370 [ext4] ext4extmapblocks+0x14f7/0x2390 [ext4] ext4mapblocks+0x569/0xea0 [ext4] ext4dowritepages+0x10f6/0x1bc0 [ext4] [...] ==================================================================

The flow of issue triggering is as follows:

// Set smbgroupprealloc to 2147483647 via sysfs ext4mbnewblocks ext4mbnormalizerequest ext4mbnormalizegrouprequest ac->acgex.felen = EXT4SB(sb)->smbgroupprealloc ext4mbregularallocator ext4mbchoosenextgroup ext4mbchoosenextgroupbestavail mbavgfragmentsizeorder order = fls(len) - 2 = 29 ext4mbfindgoodgroupavgfraglists fraglist = &sbi->smbavgfragmentsize[order] if (listempty(fraglist)) // Trigger SOOB!

At 4k block size, the length of the smbavgfragmentsize list is 14, but an oversized smbgroupprealloc is set, causing slab-out-of-bounds to be triggered by an attempt to access an element at index 29.

Add a new attrid attrclustersingroup with values in the range [0, sbi->sclusterspergroup] and declare mbgroupprealloc as that type to fix the issue. In addition avoid returning an order from mbavgfragmentsizeorder() greater than MBNUMORDERS(sb) and reduce some useless loops.

Affected Software

3 affected componentsFixes available
Linux Linux kernel>=6.5<6.6.36
Linux Linux kernel>=6.7<6.9.7
debian/linux
5.10.223-15.10.234-16.1.129-16.1.135-16.12.22-16.12.25-1

Event History

Jul 12, 2024
CVE Published
via MITRE·12:31 PM
Data Sourced
via MITRE·12:31 PM
Description
Nov 30, 2024
Data Sourced
via Ubuntu·04:46 PM
RemedyDescriptionSeverityAffected Software
Apr 23, 2025
Data Sourced
via Debian·06:15 PM
DescriptionAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-40955?

CVE-2024-40955 is classified as a medium severity vulnerability affecting the Linux kernel.

2

How do I fix CVE-2024-40955?

To fix CVE-2024-40955, upgrade to a patched version of the Linux kernel, such as 5.10.223-1 or 6.1.128-1.

3

Which versions of the Linux kernel are affected by CVE-2024-40955?

CVE-2024-40955 affects Linux kernel versions from 6.5 up to 6.6.36 and 6.7 up to 6.9.7.

4

What does CVE-2024-40955 exploit in the Linux kernel?

CVE-2024-40955 exploits a slab-out-of-bounds vulnerability in the ext4 filesystem component of the Linux kernel.

5

Is there a known workaround for CVE-2024-40955?

Currently, the recommended method to mitigate CVE-2024-40955 is to apply the available patches or upgrade the kernel to a secure version.

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