Skip to contentSkip to conversation

fs/netfs/read_collect: add to next->prev_donated

PATCH RESEND Applied Max Kellermann 4 participants 6 messages Feb 20, 2025 – Mar 19, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 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").

---
 fs/netfs/read_collect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/netfs/read_collect.c +1 -1
index 8878b46589ff..cafadfe8e858 100644
@@ -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);
 	}
Signature · 1 line
2.47.2
#1 lore raw

Hi,

Quoted 29 lines · Max Kellermann

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").

---
 fs/netfs/read_collect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/netfs/read_collect.c +1 -1
index 8878b46589ff..cafadfe8e858 100644
@@ -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);
 	}
Signature · 1 line
2.47.2

Unless I did some mistakes researching both the stable, netfs lists, did this felt through the cracks and is still missing for to be picked for the 6.12.y and 6.13.y series?

Regards,
Salvatore

maintainer Applied
#4 lore raw

Patch "fs/netfs/read_collect: add to next->prev_donated" has been added to the 6.12-stable tree

In reply to Max Kellermann

This is a note to let you know that I've just added the patch titled

    fs/netfs/read_collect: add to next->prev_donated

to the 6.12-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
fs-netfs-read_collect-add-to-next-prev_donated.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Thu Feb 20 07:27:34 2025
From: Max Kellermann <[email protected]>
Date: Thu, 20 Feb 2025 16:24:50 +0100
Subject: fs/netfs/read_collect: add to next->prev_donated
To: [email protected], [email protected], [email protected]
Cc: Max Kellermann <[email protected]>, [email protected]
Message-ID: <[email protected]>

From: Max Kellermann <[email protected]>

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").

---
 fs/netfs/read_collect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/netfs/read_collect.c +1 -1
index 8878b46589ff..cafadfe8e858 100644
@@ -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);
 	}
Signature · 7 lines
2.47.2



Patches currently in stable-queue which might be from [email protected] are

queue-6.12/fs-netfs-read_collect-add-to-next-prev_donated.patch
maintainer Applied
#5 lore raw

Patch "fs/netfs/read_collect: add to next->prev_donated" has been added to the 6.13-stable tree

In reply to Max Kellermann

This is a note to let you know that I've just added the patch titled

    fs/netfs/read_collect: add to next->prev_donated

to the 6.13-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
fs-netfs-read_collect-add-to-next-prev_donated.patch
and it can be found in the queue-6.13 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Thu Feb 20 07:27:34 2025
From: Max Kellermann <[email protected]>
Date: Thu, 20 Feb 2025 16:24:50 +0100
Subject: fs/netfs/read_collect: add to next->prev_donated
To: [email protected], [email protected], [email protected]
Cc: Max Kellermann <[email protected]>, [email protected]
Message-ID: <[email protected]>

From: Max Kellermann <[email protected]>

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").

---
 fs/netfs/read_collect.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/netfs/read_collect.c +1 -1
@@ -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);
 	}

Patches currently in stable-queue which might be from [email protected] are

queue-6.13/fs-netfs-read_collect-add-to-next-prev_donated.patch