net/rds: Bug fix ports, part 2
Subsystems (4)
Allison Henderson
maintainerv2 cover net/rds: Bug fix ports, part 2
Hi all,
This is the next batch of net/rds fixes ported from the Oracle UEK kernel, following up on the first set now in net-next [1].
This is v2 of patches 1 and 2 of "net/rds: Bug fix ports, part 2" [2], which contained two initialization-hardening ports. While re-reviewing v1's patches 3 and 4 (the fastpath-lock teardown changes) I found their locking needs more rework than a respin should carry, so they are split out and will return as their own series together with two companion fixes. The two patches here are independent of them.
[PATCH net 1/2] net/rds: reinitialize to_be_dropped on rds_send_xmit() restart
Port commit 7f52b9968d79 ("net/rds: rds_send_xmit should INIT_LIST_HEAD (&to_be_dropped) on restart")
https://github.com/oracle/linux-uek/commit/7f52b9968d79
[PATCH net 2/2] net/rds: initialize i_conn_path in rds_inc_init()
Port commit 0ec6a520da4f ("rds: rds_inc_init() should initialize the inc->i_conn_path field")
https://github.com/oracle/linux-uek/commit/0ec6a520da4f
Questions and comments appreciated!
Thanks,
Allison
v2:
- Patch 1: the comment now names rds_send_remove_from_sock() instead of vaguely blaming "the callees", and the restart-time invariant is enforced with a WARN_ON_ONCE(): entries still on the list there would keep their message reference and their RDS_MSG_ON_SOCK accounting, so a silent re-init would orphan them.
- Patch 2: for loopback the field held a live value written by rds_send_queue_rm(), not garbage; rds_loop_xmit() now uses rds_inc_path_init() so the re-initialization keeps it valid, and the commit message describes the two transports accurately.
[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/[email protected]/
Sharath Srinivasan (1):
net/rds: reinitialize to_be_dropped on rds_send_xmit() restart
William Kucharski (1):
net/rds: initialize i_conn_path in rds_inc_init()
net/rds/loop.c | 6 +++++- net/rds/recv.c | 1 + net/rds/send.c | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-)
base-commit: 4fa4977a0d900f936bcae5cd2c510be5554e8dd6
Signature · 1 line
2.25.1
Allison Henderson
maintainerPATCH v2 1/2 net/rds: reinitialize to_be_dropped on rds_send_xmit() restart
From: Sharath Srinivasan <[email protected]>
The to_be_dropped list is declared once at the top of rds_send_xmit() but the function can loop via "goto restart" after each batch. The code currently relies on rds_send_remove_from_sock() having emptied the list entry by entry (via list_del_init()) at the end of the previous batch; nothing in rds_send_xmit() itself guarantees the list head is empty when a new batch starts.
Re-initialize the list on every restart, and warn once if it is ever found non-empty there: entries left on the list at that point would keep their message reference, their RDS_MSG_ON_SOCK accounting and their pending RDS_RDMA_DROPPED notification, so a silent re-init would orphan them. This is hardening: no user-visible bug is known in the current code.
This mirrors Oracle UEK commit "net/rds: rds_send_xmit should INIT_LIST_HEAD(&to_be_dropped) on restart".
[achender: port to net-next (keep the existing LIST_HEAD declaration and
add only the restart re-init); warn if the restart invariant is violated; update commit message]
---
v2: name rds_send_remove_from_sock() in the comment; warn once if the restart-time empty-list invariant is ever violated.
v1: https://lore.kernel.org/netdev/[email protected]/
net/rds/send.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/rds/send.c +8 -0
@@ -200,6 +200,14 @@ int rds_send_xmit(struct rds_conn_path *cp) restart: batch_count =0 ; +/* The drop processing after over_batch relies on +* rds_send_remove_from_sock() emptying to_be_dropped entry by +* entry; warn if that post-condition ever stops holding, and +* re-initialize the list head. +*/ +WARN_ON_ONCE (!list_empty (&to_be_dropped)); +INIT_LIST_HEAD (&to_be_dropped); +/* * sendmsg calls here after having queued its message on the send * queue. We only have one task feeding the connection at a time. If
Signature · 1 line
2.25.1
Allison Henderson
maintainerPATCH v2 2/2 net/rds: initialize i_conn_path in rds_inc_init()
In reply to Allison HendersonFrom: William Kucharski <[email protected]>
rds_inc_init() initializes every field of the embedded rds_incoming except i_conn_path, and incomings are not zero-allocated (IB carves them out of a slab cache). The field therefore holds stale garbage for incs created by rds_ib.
The loopback transport is different: rds_loop_xmit() re-runs rds_inc_init() on the message's embedded inc after rds_send_queue_rm() has already stored the connection path in it, so there the field holds a live value rather than garbage, and a NULL store would discard it. Switch rds_loop_xmit() to rds_inc_path_init() with the connection's single path, which is exactly the value readers of the field reconstruct for a non-multipath transport.
With loopback preserving the field, initialize it to NULL in rds_inc_init() so that any future reader trips over a clean NULL pointer instead of a stale one, and so the two init helpers (rds_inc_init/rds_inc_path_init) leave the structure in an equivalent, fully-initialized state. Hardening only; no reader dereferences i_conn_path for a non-multipath transport today.
This mirrors Oracle UEK commit "rds: rds_inc_init() should initialize the inc->i_conn_path field".
[achender: port to net-next; keep loopback's i_conn_path valid by
switching rds_loop_xmit() to rds_inc_path_init(); update commit message]
---
v2: keep loopback's i_conn_path valid by switching rds_loop_xmit() to rds_inc_path_init(); rewrite the commit message - for loopback the field held a live value, not garbage.
v1: https://lore.kernel.org/netdev/[email protected]/
net/rds/loop.c | 6 +++++- net/rds/recv.c | 1 + 2 files changed, 6 insertions(+), 1 deletion(-)
net/rds/loop.c +5 -1
@@ -89,7 +89,11 @@ static int rds_loop_xmit(struct rds_connection *conn, struct rds_message *rm,BUG_ON (hdr_off || sg || off); -rds_inc_init (&rm->m_inc, conn, &conn->c_laddr); +/* rds_send_queue_rm() stored the connection path in this embedded +* inc; use the path init so the re-initialization keeps the field +* valid instead of discarding it. +*/ +rds_inc_path_init (&rm->m_inc, &conn->c_path[0 ], &conn->c_laddr);/* For the embedded inc. Matching put is in loop_inc_free() */ rds_message_addref (rm);
net/rds/recv.c +1 -0
@@ -47,6 +47,7 @@ void rds_inc_init(struct rds_incoming *inc, struct rds_connection *conn,refcount_set (&inc->i_refcount,1 );INIT_LIST_HEAD (&inc->i_item); inc->i_conn = conn; + inc->i_conn_path =NULL ; inc->i_saddr = *saddr; inc->i_usercopy.rdma_cookie =0 ; inc->i_usercopy.rx_tstamp =ktime_set (0 ,0 );
Signature · 1 line
2.25.1
Quoted 37 lines · Allison Henderson
Hi all,
This is the next batch of net/rds fixes ported from the Oracle UEK kernel, following up on the first set now in net-next [1].
This is v2 of patches 1 and 2 of "net/rds: Bug fix ports, part 2" [2], which contained two initialization-hardening ports. While re-reviewing v1's patches 3 and 4 (the fastpath-lock teardown changes) I found their locking needs more rework than a respin should carry, so they are split out and will return as their own series together with two companion fixes. The two patches here are independent of them.
[PATCH net 1/2] net/rds: reinitialize
to_be_droppedonrds_send_xmit()restart
Port commit7f52b9968d79("net/rds:rds_send_xmitshouldINIT_LIST_HEAD(&to_be_dropped) on restart")
https://github.com/oracle/linux-uek/commit/7f52b9968d79[PATCH net 2/2] net/rds: initialize
i_conn_pathinrds_inc_init()
Port commit0ec6a520da4f("rds:rds_inc_init()should initialize theinc->i_conn_pathfield")
https://github.com/oracle/linux-uek/commit/0ec6a520da4fQuestions and comments appreciated!
Thanks,
Allisonv2:
- Patch 1: the comment now namesrds_send_remove_from_sock()instead of vaguely blaming "the callees", and the restart-time invariant is enforced with aWARN_ON_ONCE(): entries still on the list there would keep their message reference and theirRDS_MSG_ON_SOCKaccounting, so a silent re-init would orphan them.
- Patch 2: for loopback the field held a live value written byrds_send_queue_rm(), not garbage;rds_loop_xmit()now usesrds_inc_path_init()so the re-initialization keeps it valid, and the commit message describes the two transports accurately.
Quoted 2 lines
[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/[email protected]/
For the series:
Paolo Abeni
maintainerRe: [PATCH net-next v2 2/2] net/rds: initialize i_conn_path in rds_inc_init()
In reply to Allison HendersonThis is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
net/rds: initialize i_conn_path in rds_inc_init()
This sets inc->i_conn_path to NULL in rds_inc_init() so the field is no longer left holding stale slab contents, and switches rds_loop_xmit() to rds_inc_path_init() so the loopback path keeps a live path pointer in the message's embedded inc.
Quoted 5 lines
net/rds/loop.c +0
-0
net/rds/loop.c static int rds_loop_xmit(struct rds_connection *conn, struct rds_message *rm, · line 96
Quoted 9 lines
net/rds/loop.c +5
-1@@ -89,7 +89,11 @@ static int rds_loop_xmit(struct rds_connection *conn, struct rds_message *rm,BUG_ON (hdr_off || sg || off); -rds_inc_init (&rm->m_inc, conn, &conn->c_laddr); +/* rds_send_queue_rm() stored the connection path in this embedded +* inc; use the path init so the re-initialization keeps the field +* valid instead of discarding it. +*/ +rds_inc_path_init (&rm->m_inc, &conn->c_path[0 ], &conn->c_laddr);
[Severity: Medium]
Does this swap silently drop the i_rx_lat_trace[] zeroing for loopback incs? rds_inc_init() in net/rds/recv.c ends with:
inc->i_usercopy.rx_tstamp = ktime_set(0, 0); memset(inc->i_rx_lat_trace, 0, sizeof(inc->i_rx_lat_trace));
while rds_inc_path_init() stops at:
inc->i_usercopy.rx_tstamp = ktime_set(0, 0); }
EXPORT_SYMBOL_GPL(rds_inc_path_init);
So after this change nothing in rds_loop_xmit() clears the array, and the RDS_MSG_RX_HDR and RDS_MSG_RX_START slots (written only by net/rds/ib_recv.c and net/rds/tcp_recv.c, never on the loopback path) are left to whatever rds_message_alloc()'s kzalloc() left behind rather than being explicitly initialized.
The array is handed to userspace as RDS_CMSG_RXPATH_LATENCY deltas in rds_cmsg_recv():
inc->i_rx_lat_trace[RDS_MSG_RX_CMSG] = local_clock(); ... t.rx_trace[i] = inc->i_rx_lat_trace[j + 1] - inc->i_rx_lat_trace[j];
Would it be preferable to move the memset() into rds_inc_path_init(), or have rds_inc_path_init() call rds_inc_init() and then assign i_conn_path? That would also cover the other rds_inc_path_init() caller in rds_tcp_data_recv(), where tinc comes from a recycled, non-zeroing kmem_cache and therefore keeps the same stale-field property this patch sets out to remove.
Quoted 8 lines
net/rds/loop.c +0
-0/* For the embedded inc. Matching put is in loop_inc_free() */ rds_message_addref (rm);net/rds/recv.c +0
-0
net/rds/recv.c void rds_inc_init(struct rds_incoming *inc, struct rds_connection *conn, · line 53
Quoted 7 lines
net/rds/recv.c +1
-0@@ -47,6 +47,7 @@ void rds_inc_init(struct rds_incoming *inc, struct rds_connection *conn,refcount_set (&inc->i_refcount,1 );INIT_LIST_HEAD (&inc->i_item); inc->i_conn = conn; + inc->i_conn_path =NULL ; inc->i_saddr = *saddr; inc->i_usercopy.rdma_cookie =0 ; inc->i_usercopy.rx_tstamp =ktime_set (0 ,0 );
[Severity: Medium]
Related to the above, the commit message says:
"and so the two init helpers (rds_inc_init/rds_inc_path_init) leave the structure in an equivalent, fully-initialized state."
Does that hold after this patch? rds_inc_init() gains i_conn_path = NULL here, but rds_inc_path_init() still lacks the memset(inc->i_rx_lat_trace, 0, sizeof(inc->i_rx_lat_trace)) that rds_inc_init() performs, so the two helpers leave i_rx_lat_trace[] in different states. Could the changelog be adjusted, or the missing memset() added to rds_inc_path_init() so the claim is accurate?
Signature · 1 line
This is an AI-generated review.
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 5 lines · On Sat, 8 Aug 2026 17:51:01 -0700 you wrote:
Hi all,
This is the next batch of net/rds fixes ported from the Oracle UEK kernel, following up on the first set now in net-next [1].
Quoted 8 lines
This is v2 of patches 1 and 2 of "net/rds: Bug fix ports, part 2" [2], which contained two initialization-hardening ports. While re-reviewing v1's patches 3 and 4 (the fastpath-lock teardown changes) I found their locking needs more rework than a respin should carry, so they are split out and will return as their own series together with two companion fixes. The two patches here are independent of them.
[...]
Here is the summary with links:
- [net-next,v2,1/2] net/rds: reinitialize to_be_dropped on rds_send_xmit() restart
https://git.kernel.org/netdev/net-next/c/a364a7c168d0 - [net-next,v2,2/2] net/rds: initialize i_conn_path in rds_inc_init() https://git.kernel.org/netdev/net-next/c/ff8376b2458d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Allison Henderson
maintainerQuoted 5 lines · Allison Henderson
Hi all,
This is the next batch of net/rds fixes ported from the Oracle UEK kernel, following up on the first set now in net-next [1].
Quoted 7 lines
This is v2 of patches 1 and 2 of "net/rds: Bug fix ports, part 2" [2], which contained two initialization-hardening ports. While re-reviewing v1's patches 3 and 4 (the fastpath-lock teardown changes) I found their locking needs more rework than a respin should carry, so they are split out and will return as their own series together with two companion fixes.
This reply is just for book keeping. As stated above, v1's patches 3 and 4 have been continued in a separate set:
[PATCH net-next 0/4] net/rds: own the fastpath locks across connection teardown
https://lore.kernel.org/all/[email protected]
Quoted 43 lines
The two patches here are independent of them.
[PATCH net 1/2] net/rds: reinitialize
to_be_droppedonrds_send_xmit()restart
Port commit7f52b9968d79("net/rds:rds_send_xmitshouldINIT_LIST_HEAD(&to_be_dropped) on restart")
https://github.com/oracle/linux-uek/commit/7f52b9968d79[PATCH net 2/2] net/rds: initialize
i_conn_pathinrds_inc_init()
Port commit0ec6a520da4f("rds:rds_inc_init()should initialize theinc->i_conn_pathfield")
https://github.com/oracle/linux-uek/commit/0ec6a520da4fQuestions and comments appreciated!
Thanks,
Allisonv2:
- Patch 1: the comment now namesrds_send_remove_from_sock()instead of vaguely blaming "the callees", and the restart-time invariant is enforced with aWARN_ON_ONCE(): entries still on the list there would keep their message reference and theirRDS_MSG_ON_SOCKaccounting, so a silent re-init would orphan them.
- Patch 2: for loopback the field held a live value written byrds_send_queue_rm(), not garbage;rds_loop_xmit()now usesrds_inc_path_init()so the re-initialization keeps it valid, and the commit message describes the two transports accurately.[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/[email protected]/Sharath Srinivasan (1):
net/rds: reinitializeto_be_droppedonrds_send_xmit()restartWilliam Kucharski (1):
net/rds: initializei_conn_pathinrds_inc_init()net/rds/loop.c | 6 +++++- net/rds/recv.c | 1 + net/rds/send.c | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-)base-commit:
4fa4977a0d900f936bcae5cd2c510be5554e8dd6