# CVE-2024-41058: cachefiles: fix slab-use-after-free in fscache\_withdraw\_volume()

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

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; 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.36% (percentile 22, 2026-11-28)
- **CWE:** CWE-416
- **Published:** 2024-07-29T14:57:20.894Z
- **Modified:** 2026-06-17T07:47:11.263Z

## Who should check

- Anyone running Linux \>= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, \< 90f17e47f1e209c6a3c92a1d038a0a80c95c460e; \>= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, \< 9dd7f5663899ea13a6a73216106d9c13c37453e3; \>= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, \< 38b88d544216f806d93a273a62ff8ebe82254003; \>= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, \< 522018a0de6b6fcce60c04f86dfc5f0e4b6a1b36
- Anyone running Linux 5.17

## Description

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

cachefiles: fix slab-use-after-free in fscache\_withdraw\_volume()

We got the following issue in our fault injection stress test:

==================================================================
BUG: KASAN: slab-use-after-free in fscache\_withdraw\_volume+0x2e1/0x370
Read of size 4 at addr ffff88810680be08 by task ondemand-04-dae/5798

CPU: 0 PID: 5798 Comm: ondemand-04-dae Not tainted 6.8.0-dirty \#565
Call Trace:
 kasan\_check\_range+0xf6/0x1b0
 fscache\_withdraw\_volume+0x2e1/0x370
 cachefiles\_withdraw\_volume+0x31/0x50
 cachefiles\_withdraw\_cache+0x3ad/0x900
 cachefiles\_put\_unbind\_pincount+0x1f6/0x250
 cachefiles\_daemon\_release+0x13b/0x290
 \_\_fput+0x204/0xa00
 task\_work\_run+0x139/0x230

Allocated by task 5820:
 \_\_kmalloc+0x1df/0x4b0
 fscache\_alloc\_volume+0x70/0x600
 \_\_fscache\_acquire\_volume+0x1c/0x610
 erofs\_fscache\_register\_volume+0x96/0x1a0
 erofs\_fscache\_register\_fs+0x49a/0x690
 erofs\_fc\_fill\_super+0x6c0/0xcc0
 vfs\_get\_super+0xa9/0x140
 vfs\_get\_tree+0x8e/0x300
 do\_new\_mount+0x28c/0x580
 \[...\]

Freed by task 5820:
 kfree+0xf1/0x2c0
 fscache\_put\_volume.part.0+0x5cb/0x9e0
 erofs\_fscache\_unregister\_fs+0x157/0x1b0
 erofs\_kill\_sb+0xd9/0x1c0
 deactivate\_locked\_super+0xa3/0x100
 vfs\_get\_super+0x105/0x140
 vfs\_get\_tree+0x8e/0x300
 do\_new\_mount+0x28c/0x580
 \[...\]
==================================================================

Following is the process that triggers the issue:

        mount failed         \|         daemon exit
------------------------------------------------------------
 deactivate\_locked\_super        cachefiles\_daemon\_release
  erofs\_kill\_sb
   erofs\_fscache\_unregister\_fs
    fscache\_relinquish\_volume
     \_\_fscache\_relinquish\_volume
      fscache\_put\_volume(fscache\_volume, fscache\_volume\_put\_relinquish)
       zero = \_\_refcount\_dec\_and\_test(&fscache\_volume-\>ref, &ref);
                                 cachefiles\_put\_unbind\_pincount
                                  cachefiles\_daemon\_unbind
                                   cachefiles\_withdraw\_cache
                                    cachefiles\_withdraw\_volumes
                                     list\_del\_init(&volume-\>cache\_link)
       fscache\_free\_volume(fscache\_volume)
        cache-\>ops-\>free\_volume
         cachefiles\_free\_volume
          list\_del\_init(&cachefiles\_volume-\>cache\_link);
        kfree(fscache\_volume)
                                     cachefiles\_withdraw\_volume
                                      fscache\_withdraw\_volume
                                       fscache\_volume-\>n\_accesses
                                       // fscache\_volume UAF !!!

The fscache\_volume in cache-\>volumes must not have been freed yet, but its
reference count may be 0. So use the new fscache\_try\_get\_volume() helper
function try to get its reference count.

If the reference count of fscache\_volume is 0, fscache\_put\_volume() is
freeing it, so wait for it to be removed from cache-\>volumes.

If its reference count is not 0, call cachefiles\_withdraw\_volume() with
reference count protection to avoid the above issue.

## Affected and fixed versions

- Linux: \>= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, \< 90f17e47f1e209c6a3c92a1d038a0a80c95c460e; \>= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, \< 9dd7f5663899ea13a6a73216106d9c13c37453e3; \>= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, \< 38b88d544216f806d93a273a62ff8ebe82254003; \>= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, \< 522018a0de6b6fcce60c04f86dfc5f0e4b6a1b36 (cvelist)
- Linux: 5.17 (cvelist)

## Mitigation

- Upgrade Linux to 522018a0de6b6fcce60c04f86dfc5f0e4b6a1b36 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-41058. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2024-41058.md
Affected: Linux >= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, < 90f17e47f1e209c6a3c92a1d038a0a80c95c460e; >= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, < 9dd7f5663899ea13a6a73216106d9c13c37453e3; >= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, < 38b88d544216f806d93a273a62ff8ebe82254003; >= fe2140e2f57fef8562e0f9b…
Fixed in: Linux 90f17e47f1e209c6a3c92a1d038a0a80c95c460e, Linux 9dd7f5663899ea13a6a73216106d9c13c37453e3, Linux 38b88d544216f806d93a273a62ff8ebe82254003, Linux 522018a0de6b6fcce60c04f86dfc5f0e4b6a1b36

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

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

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

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

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

Linux \>= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, \< 90f17e47f1e209c6a3c92a1d038a0a80c95c460e; \>= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, \< 9dd7f5663899ea13a6a73216106d9c13c37453e3; \>= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, \< 38b88d544216f806d93a273a62ff8ebe82254003; \>= fe2140e2f57fef8562e0f9b7cd447d2b08dc2f35, \< 522018a0de6b6fcce60c04f86dfc5f0e4b6a1b36; Linux 5.17.

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

Yes. Fixed in Linux 90f17e47f1e209c6a3c92a1d038a0a80c95c460e, Linux 9dd7f5663899ea13a6a73216106d9c13c37453e3, Linux 38b88d544216f806d93a273a62ff8ebe82254003, Linux 522018a0de6b6fcce60c04f86dfc5f0e4b6a1b36. Upgrade Linux to 522018a0de6b6fcce60c04f86dfc5f0e4b6a1b36 or later.

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

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/90f17e47f1e209c6a3c92a1d038a0a80c95c460e>
- patch: <https://git.kernel.org/stable/c/9dd7f5663899ea13a6a73216106d9c13c37453e3>
- patch: <https://git.kernel.org/stable/c/38b88d544216f806d93a273a62ff8ebe82254003>
- patch: <https://git.kernel.org/stable/c/522018a0de6b6fcce60c04f86dfc5f0e4b6a1b36>
- other: <https://lists.debian.org/debian-lts-announce/2025/01/msg00001.html>

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

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