Skip to content

Commit e25cec3

Browse files
MaxKellermanngregkh
authored andcommitted
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: ee4cdf7 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0e464d5 commit e25cec3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/netfs/read_collect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static bool netfs_consume_read_data(struct netfs_io_subrequest *subreq, bool was
284284
netfs_trace_donate_to_deferred_next);
285285
} else {
286286
next = list_next_entry(subreq, rreq_link);
287-
WRITE_ONCE(next->prev_donated, excess);
287+
WRITE_ONCE(next->prev_donated, next->prev_donated + excess);
288288
trace_netfs_donate(rreq, subreq, next, excess,
289289
netfs_trace_donate_to_next);
290290
}

0 commit comments

Comments
 (0)