# CVE-2024-40998: ext4: fix uninitialized ratelimit\_state-\>lock access in \_\_ext4\_fill\_super()

> 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-908
- **Published:** 2024-07-12T12:37:39.823Z
- **Modified:** 2026-10-30T13:17:30.080Z

## Who should check

- Anyone running Linux \>= efbed4dc5857f845d787e406ce85097d1ccc5c4f, \< 1e2df0ee0afd6d4b436a740f04f7a759e6531005; \>= efbed4dc5857f845d787e406ce85097d1ccc5c4f, \< 23afcd52af06880c6c913a0ad99022b8937b575c; \>= efbed4dc5857f845d787e406ce85097d1ccc5c4f, \< 645267906944a9aeec9d5c56ee24a9096a288798; \>= efbed4dc5857f845d787e406ce85097d1ccc5c4f, \< b4b4fda34e535756f9e774fb2d09c4537b7dfd1c
- Anyone running Linux 3.13

## Description

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

ext4: fix uninitialized ratelimit\_state-\>lock access in \_\_ext4\_fill\_super()

In the following concurrency we will access the uninitialized rs-\>lock:

ext4\_fill\_super
  ext4\_register\_sysfs
   // sysfs registered msg\_ratelimit\_interval\_ms
                             // Other processes modify rs-\>interval to
                             // non-zero via msg\_ratelimit\_interval\_ms
  ext4\_orphan\_cleanup
    ext4\_msg(sb, KERN\_INFO, "Errors on filesystem, "
      \_\_ext4\_msg
        \_\_\_ratelimit(&(EXT4\_SB(sb)-\>s\_msg\_ratelimit\_state)
          if (!rs-\>interval)  // do nothing if interval is 0
            return 1;
          raw\_spin\_trylock\_irqsave(&rs-\>lock, flags)
            raw\_spin\_trylock(lock)
              \_raw\_spin\_trylock
                \_\_raw\_spin\_trylock
                  spin\_acquire(&lock-\>dep\_map, 0, 1, \_RET\_IP\_)
                    lock\_acquire
                      \_\_lock\_acquire
                        register\_lock\_class
                          assign\_lock\_key
                            dump\_stack();
  ratelimit\_state\_init(&sbi-\>s\_msg\_ratelimit\_state, 5 \* HZ, 10);
    raw\_spin\_lock\_init(&rs-\>lock);
    // init rs-\>lock here

and get the following dump\_stack:

=========================================================
INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe
you didn't initialize this object before use?
turning off the locking correctness validator.
CPU: 12 PID: 753 Comm: mount Tainted: G E 6.7.0-rc6-next-20231222 \#504
\[...\]
Call Trace:
 dump\_stack\_lvl+0xc5/0x170
 dump\_stack+0x18/0x30
 register\_lock\_class+0x740/0x7c0
 \_\_lock\_acquire+0x69/0x13a0
 lock\_acquire+0x120/0x450
 \_raw\_spin\_trylock+0x98/0xd0
 \_\_\_ratelimit+0xf6/0x220
 \_\_ext4\_msg+0x7f/0x160 \[ext4\]
 ext4\_orphan\_cleanup+0x665/0x740 \[ext4\]
 \_\_ext4\_fill\_super+0x21ea/0x2b10 \[ext4\]
 ext4\_fill\_super+0x14d/0x360 \[ext4\]
\[...\]
=========================================================

Normally interval is 0 until s\_msg\_ratelimit\_state is initialized, so
\_\_\_ratelimit() does nothing. But registering sysfs precedes initializing
rs-\>lock, so it is possible to change rs-\>interval to a non-zero value
via the msg\_ratelimit\_interval\_ms interface of sysfs while rs-\>lock is
uninitialized, and then a call to ext4\_msg triggers the problem by
accessing an uninitialized rs-\>lock. Therefore register sysfs after all
initializations are complete to avoid such problems.

## Affected and fixed versions

- Linux: \>= efbed4dc5857f845d787e406ce85097d1ccc5c4f, \< 1e2df0ee0afd6d4b436a740f04f7a759e6531005; \>= efbed4dc5857f845d787e406ce85097d1ccc5c4f, \< 23afcd52af06880c6c913a0ad99022b8937b575c; \>= efbed4dc5857f845d787e406ce85097d1ccc5c4f, \< 645267906944a9aeec9d5c56ee24a9096a288798; \>= efbed4dc5857f845d787e406ce85097d1ccc5c4f, \< b4b4fda34e535756f9e774fb2d09c4537b7dfd1c (cvelist)
- Linux: 3.13 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2024-40998.md
Affected: Linux >= efbed4dc5857f845d787e406ce85097d1ccc5c4f, < 1e2df0ee0afd6d4b436a740f04f7a759e6531005; >= efbed4dc5857f845d787e406ce85097d1ccc5c4f, < 23afcd52af06880c6c913a0ad99022b8937b575c; >= efbed4dc5857f845d787e406ce85097d1ccc5c4f, < 645267906944a9aeec9d5c56ee24a9096a288798; >= efbed4dc5857f845d787e40…
Fixed in: Linux 1e2df0ee0afd6d4b436a740f04f7a759e6531005, Linux 23afcd52af06880c6c913a0ad99022b8937b575c, Linux 645267906944a9aeec9d5c56ee24a9096a288798

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-40998 being exploited?

There is no confirmed exploitation: CVE-2024-40998 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-40998?

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

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

Linux \>= efbed4dc5857f845d787e406ce85097d1ccc5c4f, \< 1e2df0ee0afd6d4b436a740f04f7a759e6531005; \>= efbed4dc5857f845d787e406ce85097d1ccc5c4f, \< 23afcd52af06880c6c913a0ad99022b8937b575c; \>= efbed4dc5857f845d787e406ce85097d1ccc5c4f, \< 645267906944a9aeec9d5c56ee24a9096a288798; \>= efbed4dc5857f845d787e406ce85097d1ccc5c4f, \< b4b4fda34e535756f9e774fb2d09c4537b7dfd1c; Linux 3.13.

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

Yes. Fixed in Linux 1e2df0ee0afd6d4b436a740f04f7a759e6531005, Linux 23afcd52af06880c6c913a0ad99022b8937b575c, Linux 645267906944a9aeec9d5c56ee24a9096a288798. No fix listed yet: follow the vendor advisory.

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

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/23afcd52af06880c6c913a0ad99022b8937b575c>
- patch: <https://git.kernel.org/stable/c/645267906944a9aeec9d5c56ee24a9096a288798>
- patch: <https://git.kernel.org/stable/c/b4b4fda34e535756f9e774fb2d09c4537b7dfd1c>
- other: <https://git.kernel.org/stable/c/1e2df0ee0afd6d4b436a740f04f7a759e6531005>

## 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-40998>

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