From: Max Kellermann Date: Thu, 20 Feb 2025 15:24:50 +0000 (+0100) Subject: fs/netfs/read_collect: add to next->prev_donated X-Git-Tag: v6.12.20~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62b9ad7e52d4777f7e775ee1f0ad2452f6041024;p=thirdparty%2Fkernel%2Fstable.git fs/netfs/read_collect: add to next->prev_donated If multiple subrequests donate data to the same "next" request (depending on the subrequest completion order), each of them would overwrite the `prev_donated` field, causing data corruption and a BUG() crash ("Can't donate prior to front"). Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading") Closes: https://lore.kernel.org/netfs/CAKPOu+_4mUwYgQtRTbXCmi+-k3PGvLysnPadkmHOyB7Gz0iSMA@mail.gmail.com/ Cc: stable@vger.kernel.org Signed-off-by: Max Kellermann Signed-off-by: David Howells Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c index 3b9461f5e712e..eae415efae24a 100644 --- a/fs/netfs/read_collect.c +++ b/fs/netfs/read_collect.c @@ -284,7 +284,7 @@ donation_changed: netfs_trace_donate_to_deferred_next); } else { next = list_next_entry(subreq, rreq_link); - WRITE_ONCE(next->prev_donated, excess); + WRITE_ONCE(next->prev_donated, next->prev_donated + excess); trace_netfs_donate(rreq, subreq, next, excess, netfs_trace_donate_to_next); }