CVE-2024-41057: cachefiles: fix slab-use-after-free in cachefiles_withdraw_cookie()
In the Linux kernel, the following vulnerability has been resolved:
cachefiles: fix slab-use-after-free in cachefiles_withdraw_cookie()
We got the following issue in our fault injection stress test:
==================================================================
BUG: KASAN: slab-use-after-free in cachefiles_withdraw_cookie+0x4d9/0x600
Read of size 8 at addr ffff888118efc000 by task kworker/u78:0/109
CPU: 13 PID: 109 Comm: kworker/u78:0 Not tainted 6.8.0-dirty #566
Call Trace:
<TASK>
kasan_report+0x93/0xc0
cachefiles_withdraw_cookie+0x4d9/0x600
fscache_cookie_state_machine+0x5c8/0x1230
fscache_cookie_worker+0x91/0x1c0
process_one_work+0x7fa/0x1800
[...]
Allocated by task 117:
kmalloc_trace+0x1b3/0x3c0
cachefiles_acquire_volume+0xf3/0x9c0
fscache_create_volume_work+0x97/0x150
process_one_work+0x7fa/0x1800
[...]
Freed by task 120301:
kfree+0xf1/0x2c0
cachefiles_withdraw_cache+0x3fa/0x920
cachefiles_put_unbind_pincount+0x1f6/0x250
cachefiles_daemon_release+0x13b/0x290
__fput+0x204/0xa00
task_work_run+0x139/0x230
do_exit+0x87a/0x29b0
[...]
==================================================================
Following is the process that triggers the issue:
p1 | p2
------------------------------------------------------------
fscache_begin_lookup
fscache_begin_volume_access
fscache_cache_is_live(fscache_cache)
cachefiles_daemon_release
cachefiles_put_unbind_pincount
cachefiles_daemon_unbind
cachefiles_withdraw_cache
fscache_withdraw_cache
fscache_set_cache_state(cache, FSCACHE_CACHE_IS_WITHDRAWN);
cachefiles_withdraw_objects(cache)
fscache_wait_for_objects(fscache)
atomic_read(&fscache_cache->object_count) == 0
fscache_perform_lookup
cachefiles_lookup_cookie
cachefiles_alloc_object
refcount_set(&object->ref, 1);
object->volume = volume
fscache_count_object(vcookie->cache);
atomic_inc(&fscache_cache->object_count)
cachefiles_withdraw_volumes
cachefiles_withdraw_volume
fscache_withdraw_volume
__cachefiles_free_volume
kfree(cachefiles_volume)
fscache_cookie_state_machine
cachefiles_withdraw_cookie
cache = object->volume->cache;
// cachefiles_volume UAF !!!
After setting FSCACHE_CACHE_IS_WITHDRAWN, wait for all the cookie lookups
to complete first, and then wait for fscache_cache->object_count == 0 to
avoid the cookie exiting after the volume has been freed and triggering
the above issue. Therefore call fscache_withdraw_volume() before calling
cachefiles_withdraw_objects().
This way, after setting FSCACHE_CACHE_IS_WITHDRAWN, only the following two
cases will occur:
1) fscache_begin_lookup fails in fscache_begin_volume_access().
2) fscache_withdraw_volume() will ensure that fscache_count_object() has
been executed before calling fscache_wait_for_objects().
Security readout for executives and security teams
Plain-English summary
A race condition in the Linux CacheFiles subsystem can access memory after it has been freed. A local, low-privileged user may be able to trigger serious confidentiality, integrity, or availability effects. The issue was reproduced during fault-injection stress testing; the supplied sources do not establish real-world exploitation.
Executive priority
Treat this as a timely kernel-maintenance priority, especially on shared Linux systems using CacheFiles. It is high severity but not evidenced as remotely or actively exploited. Expedite normal vendor kernel updates and reboot verification; prioritize exposed multi-user environments over systems where the subsystem is absent or unused.
Technical view
During concurrent cache withdrawal and cookie lookup, a CacheFiles volume can be freed before cachefiles_withdraw_cookie() dereferences it. The correction changes withdrawal ordering so in-flight lookups and object accounting complete before volume memory is released. The reported KASAN finding occurred on a development Linux 6.8 kernel.
Likely exposure
Exposure requires an affected Linux kernel and use of the relevant CacheFiles/FS-Cache path. CVSS indicates local access, low complexity, low privileges, and no user interaction. Internet reachability alone does not create remote exposure. The bundled version list is ambiguous, so confirm distribution backports and package status through vendor guidance.
Exploitation context
CISA KEV status is false, and no supplied source reports active exploitation or a public weaponized exploit. Evidence is limited to a fault-injection stress-test reproduction. Exploitability and resulting impact may depend on kernel configuration, CacheFiles use, workload timing, and access by a local low-privileged user.
Researcher notes
The race occurs when cache withdrawal overlaps a lookup that allocates an object referencing a volume. Volume memory may then be freed before cookie withdrawal reads object->volume->cache. The fix calls fscache_withdraw_volume() before cachefiles_withdraw_objects(), closing the accounting window. The bundle supplies no CWE classification or confirmed exploitation evidence.
Mitigation direction
Identify hosts running Linux kernels that use CacheFiles or FS-Cache.
Apply a supported vendor kernel containing the linked stable correction, then reboot into it.
If updating is delayed, consult distribution guidance for supported mitigations; none are specified in this bundle.
Prioritize multi-user or untrusted-workload systems where local low-privileged access exists.
Validation and detection
Record the running kernel version, not only the installed package version.
Confirm whether CacheFiles or FS-Cache is configured, loaded, or actively used on each host.
Map distribution kernel builds to vendor advisories or the linked stable commits.
After remediation, verify the running kernel includes the correction and review logs for memory-safety symptoms.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cve · low confidence lookup
CVE-2024-41057 mapping review
Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.