Skip to content

Commit 05b5232

Browse files
committed
Merge: CVE-2024-57942: netfs: Fix ceph copy to cache on write-begin
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/238 JIRA: https://issues.redhat.com/browse/RHEL-75655 CVE: CVE-2024-57942 ``` 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. Fixes: 796a404 ("netfs: In readahead, put the folio refs as soon extracted") Reported-by: Max Kellermann <max.kellermann@ionos.com> Closes: https://lore.kernel.org/r/CAKPOu+_4m80thNy5_fvROoxBm689YtA0dZ-=gcmkzwYSY4syqw@mail.gmail.com/ Signed-off-by: David Howells <dhowells@redhat.com> Link: https://lore.kernel.org/r/20241213135013.2964079-10-dhowells@redhat.com Fixes: ee4cdf7 ("netfs: Speed up buffered reading") cc: Jeff Layton <jlayton@kernel.org> cc: Ilya Dryomov <idryomov@gmail.com> cc: Xiubo Li <xiubli@redhat.com> cc: netfs@lists.linux.dev cc: ceph-devel@vger.kernel.org cc: linux-fsdevel@vger.kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org> (cherry picked from commit 38cf8e9) ``` Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com> --- <small>Created 2025-01-21 16:47 UTC by backporter - [KWF FAQ](https://red.ht/kernel_workflow_doc) - [Slack #team-kernel-workflow](https://redhat-internal.slack.com/archives/C04LRUPMJQ5) - [Source](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/webhook/utils/backporter.py) - [Documentation](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/docs/README.backporter.md) - [Report an issue](https://gitlab.com/cki-project/kernel-workflow/-/issues/new?issue%5Btitle%5D=backporter%20webhook%20issue)</small> Approved-by: David Howells <dhowells@redhat.com> Approved-by: Paulo Alcantara <paalcant@redhat.com> Approved-by: Benjamin Coddington <bcodding@redhat.com> Approved-by: Alex Markuze <amarkuze@redhat.com> Merged-by: Julio Faracco <jfaracco@redhat.com>
2 parents 66c7884 + 5d41f47 commit 05b5232

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/netfs/read_collect.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,14 @@ static void netfs_unlock_read_folio(struct netfs_io_subrequest *subreq,
6262
} else {
6363
trace_netfs_folio(folio, netfs_folio_trace_read_done);
6464
}
65+
66+
folioq_clear(folioq, slot);
6567
} else {
6668
// TODO: Use of PG_private_2 is deprecated.
6769
if (test_bit(NETFS_SREQ_COPY_TO_CACHE, &subreq->flags))
6870
netfs_pgpriv2_mark_copy_to_cache(subreq, rreq, folioq, slot);
71+
else
72+
folioq_clear(folioq, slot);
6973
}
7074

7175
if (!test_bit(NETFS_RREQ_DONT_UNLOCK_FOLIOS, &rreq->flags)) {
@@ -77,8 +81,6 @@ static void netfs_unlock_read_folio(struct netfs_io_subrequest *subreq,
7781
folio_unlock(folio);
7882
}
7983
}
80-
81-
folioq_clear(folioq, slot);
8284
}
8385

8486
/*

0 commit comments

Comments
 (0)