# CVE-2024-40955: ext4: fix slab-out-of-bounds in ext4\_mb\_find\_good\_group\_avg\_frag\_lists()

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.30% (percentile 16, 2026-11-26)
- **CWE:** CWE-787
- **Published:** 2024-07-12T12:31:58.328Z
- **Modified:** 2026-06-17T07:46:56.950Z

## Who should check

- Anyone running Linux \>= 7e170922f06bf46effa7c57f6035fc463d6edc7e, \< 677ff4589f1501578fa903a25bb14831d0607992; \>= 7e170922f06bf46effa7c57f6035fc463d6edc7e, \< b829687ae1229224262bcabf49accfa2dbf8db06; \>= 7e170922f06bf46effa7c57f6035fc463d6edc7e, \< 13df4d44a3aaabe61cd01d277b6ee23ead2a5206
- Anyone running Linux 6.5

## Description

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

ext4: fix slab-out-of-bounds in ext4\_mb\_find\_good\_group\_avg\_frag\_lists()

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/mb\_group\_prealloc
    echo test \> /tmp/test/file && sync

==================================================================
BUG: KASAN: slab-out-of-bounds in ext4\_mb\_find\_good\_group\_avg\_frag\_lists+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:
 dump\_stack\_lvl+0x2c/0x50
 kasan\_report+0xb6/0xf0
 ext4\_mb\_find\_good\_group\_avg\_frag\_lists+0x8a/0x200 \[ext4\]
 ext4\_mb\_regular\_allocator+0x19e9/0x2370 \[ext4\]
 ext4\_mb\_new\_blocks+0x88a/0x1370 \[ext4\]
 ext4\_ext\_map\_blocks+0x14f7/0x2390 \[ext4\]
 ext4\_map\_blocks+0x569/0xea0 \[ext4\]
 ext4\_do\_writepages+0x10f6/0x1bc0 \[ext4\]
\[...\]
==================================================================

The flow of issue triggering is as follows:

// Set s\_mb\_group\_prealloc to 2147483647 via sysfs
ext4\_mb\_new\_blocks
  ext4\_mb\_normalize\_request
    ext4\_mb\_normalize\_group\_request
      ac-\>ac\_g\_ex.fe\_len = EXT4\_SB(sb)-\>s\_mb\_group\_prealloc
  ext4\_mb\_regular\_allocator
    ext4\_mb\_choose\_next\_group
      ext4\_mb\_choose\_next\_group\_best\_avail
        mb\_avg\_fragment\_size\_order
          order = fls(len) - 2 = 29
        ext4\_mb\_find\_good\_group\_avg\_frag\_lists
          frag\_list = &sbi-\>s\_mb\_avg\_fragment\_size\[order\]
          if (list\_empty(frag\_list)) // Trigger SOOB!

At 4k block size, the length of the s\_mb\_avg\_fragment\_size list is 14,
but an oversized s\_mb\_group\_prealloc is set, causing slab-out-of-bounds
to be triggered by an attempt to access an element at index 29.

Add a new attr\_id attr\_clusters\_in\_group with values in the range
\[0, sbi-\>s\_clusters\_per\_group\] and declare mb\_group\_prealloc as
that type to fix the issue. In addition avoid returning an order
from mb\_avg\_fragment\_size\_order() greater than MB\_NUM\_ORDERS(sb)
and reduce some useless loops.

## Affected and fixed versions

- Linux: \>= 7e170922f06bf46effa7c57f6035fc463d6edc7e, \< 677ff4589f1501578fa903a25bb14831d0607992; \>= 7e170922f06bf46effa7c57f6035fc463d6edc7e, \< b829687ae1229224262bcabf49accfa2dbf8db06; \>= 7e170922f06bf46effa7c57f6035fc463d6edc7e, \< 13df4d44a3aaabe61cd01d277b6ee23ead2a5206 (cvelist)
- Linux: 6.5 (cvelist)

## Mitigation

- Upgrade Linux to 13df4d44a3aaabe61cd01d277b6ee23ead2a5206 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2024-40955. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2024-40955.md
Affected: Linux >= 7e170922f06bf46effa7c57f6035fc463d6edc7e, < 677ff4589f1501578fa903a25bb14831d0607992; >= 7e170922f06bf46effa7c57f6035fc463d6edc7e, < b829687ae1229224262bcabf49accfa2dbf8db06; >= 7e170922f06bf46effa7c57f6035fc463d6edc7e, < 13df4d44a3aaabe61cd01d277b6ee23ead2a5206; Linux 6.5
Fixed in: Linux 677ff4589f1501578fa903a25bb14831d0607992, Linux 13df4d44a3aaabe61cd01d277b6ee23ead2a5206

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2024-40955 being exploited?

There is no confirmed exploitation: CVE-2024-40955 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.30% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2024-40955?

Medium: CVSS 5.5 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2024-40955?

Linux \>= 7e170922f06bf46effa7c57f6035fc463d6edc7e, \< 677ff4589f1501578fa903a25bb14831d0607992; \>= 7e170922f06bf46effa7c57f6035fc463d6edc7e, \< b829687ae1229224262bcabf49accfa2dbf8db06; \>= 7e170922f06bf46effa7c57f6035fc463d6edc7e, \< 13df4d44a3aaabe61cd01d277b6ee23ead2a5206; Linux 6.5.

### Is there a fix for CVE-2024-40955?

Yes. Fixed in Linux 677ff4589f1501578fa903a25bb14831d0607992, Linux 13df4d44a3aaabe61cd01d277b6ee23ead2a5206. Upgrade Linux to 13df4d44a3aaabe61cd01d277b6ee23ead2a5206 or later.

### How do I check if I'm affected by CVE-2024-40955?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/677ff4589f1501578fa903a25bb14831d0607992>
- patch: <https://git.kernel.org/stable/c/b829687ae1229224262bcabf49accfa2dbf8db06>
- patch: <https://git.kernel.org/stable/c/13df4d44a3aaabe61cd01d277b6ee23ead2a5206>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2024-40955>

HTML: <https://flawdb.com/CVE-2024-40955> · JSON: <https://flawdb.com/api/v1/entries/CVE-2024-40955>
