CVE-2024-57942: netfs: Fix ceph copy to cache on write-begin
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
netfs: Fix ceph copy to cache on write-begin
At the end of netfs_unlock_read_folio() in which folios are marked appropriately for copying to the cache (either with by being marked dirty and having their private data set or by having PG_private_2 set) and then unlocked, the folio_queue struct has the entry pointing to the folio cleared. This presents a problem for netfs_pgpriv2_write_to_the_cache(), which is used to write folios marked with PG_private_2 to the cache as it expects to be able to trawl the folio_queue list thereafter to find the relevant folios, leading to a hang.
Fix this by not clearing the folio_queue entry if we're going to do the deprecated copy-to-cache. The clearance will be done instead as the folios are written to the cache.
This can be reproduced by starting cachefiles, mounting a ceph filesystem with "-o fsc" and writing to it.
The Linux kernel CVE team has assigned CVE-2024-57942 to this issue.
Affected and fixed versions
===========================
Issue introduced in 6.12 with commit 796a4049640b54cb1daf9e7fe543292c5ca02c74 and fixed in 6.12.10 with commit 43b8d3249b0b71bad239d42dbe08ce6c938ba000 Issue introduced in 6.12 with commit 796a4049640b54cb1daf9e7fe543292c5ca02c74 and fixed in 6.13 with commit 38cf8e945721ffe708fa675507465da7f4f2a9f7
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2024-57942
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
fs/netfs/read_collect.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/43b8d3249b0b71bad239d42dbe08ce6c938ba000 https://git.kernel.org/stable/c/38cf8e945721ffe708fa675507465da7f4f2a9f7