netfs.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] fs/netfs/read_collect: add to next->prev_donated
@ 2025-02-20 15:24 Max Kellermann
  2025-03-15 14:06 ` Salvatore Bonaccorso
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Max Kellermann @ 2025-02-20 15:24 UTC (permalink / raw)
  To: dhowells, netfs, linux-kernel; +Cc: Max Kellermann, stable

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 <max.kellermann@ionos.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---
 fs/netfs/read_collect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c
index 8878b46589ff..cafadfe8e858 100644
--- a/fs/netfs/read_collect.c
+++ b/fs/netfs/read_collect.c
@@ -284,7 +284,7 @@ static bool netfs_consume_read_data(struct netfs_io_subrequest *subreq, bool was
 				   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);
 	}
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-03-19 14:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-20 15:24 [PATCH RESEND] fs/netfs/read_collect: add to next->prev_donated Max Kellermann
2025-03-15 14:06 ` Salvatore Bonaccorso
2025-03-17 10:03 ` David Howells
2025-03-19 14:19   ` Greg Kroah-Hartman
2025-03-19 14:20 ` Patch "fs/netfs/read_collect: add to next->prev_donated" has been added to the 6.12-stable tree gregkh
2025-03-19 14:20 ` Patch "fs/netfs/read_collect: add to next->prev_donated" has been added to the 6.13-stable tree gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).