RDS/IB: validate receive fragment completions
Subsystems (5)
PATCH v4 1/1 RDS/IB: validate receive fragment completions
rds_ib_process_recv() accounts every receive fragment as contributing min(i_recv_data_rem, RDS_FRAG_SIZE) bytes, regardless of the completion length. When a completion is shorter than the header-declared amount, receive accounting can advance beyond the payload supplied by the completion.
Only an IB_WC_RECV completion has the buffer layout expected by this receive path. Other successful completion opcodes must not be interpreted as ordinary receive completions.
Reject successful completions with any other opcode before processing their length. For ordinary receive completions, require enough payload to cover the amount accounted to the fragment before linking its page into the incoming message.
This is compatible with the current transmit paths. MSG_ZEROCOPY is restricted to RDS/TCP, while RDS/IB copied and page-vector messages use full-sized non-final scatterlist entries.
Found during an LLM-assisted source audit and validated under KMSAN with a malformed short receive completion.
---
Changes in v4:
- Reject malformed short fragments instead of normalizing their length.
- Reject successful non-IB_WC_RECV completions before trusting byte_len.
- Explain why MSG_ZEROCOPY cannot reach the RDS/IB transmit path.
- Add the source-audit and KMSAN discovery details.
- Remove the author's self-Reported-by while retaining linked reporters.
- Leave maximum h_len validation to a separate investigation.
v3: https://lore.kernel.org/netdev/[email protected]/
v2: https://lore.kernel.org/netdev/[email protected]/
net/rds/ib_recv.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
net/rds/ib_recv.c +12 -1
@@ -949,6 +949,12 @@ static void rds_ib_process_recv(struct rds_connection *conn, } } +if (data_len <min_t (u32, ic->i_recv_data_rem,RDS_FRAG_SIZE )) { +rds_ib_conn_error (conn, +"fragment shorter than header-declared length; forcing reconnect\n" ); + goto done; + } +list_add_tail (&recv->r_frag->f_item, &ibinc->ii_frags); recv->r_frag =NULL ;
@@ -1004,7 +1010,12 @@ void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic,* event is processed. */ if (wc->status ==IB_WC_SUCCESS ) { -rds_ib_process_recv (conn, recv, wc->byte_len, state); +if (wc->opcode !=IB_WC_RECV ) +rds_ib_conn_error (conn, +"recv completion had unexpected opcode %u, disconnecting and reconnecting\n" , + wc->opcode); +else +rds_ib_process_recv (conn, recv, wc->byte_len, state); }else {/* We expect errors as the qp is drained during shutdown */ if (rds_conn_up (conn) ||rds_conn_connecting (conn))
base-commit: 72d3fcf802c45d00b300f25b848a93c3a2bd7c7e
Signature · 1 line
2.43.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 15 lines
rds_ib_process_recv()accounts every receive fragment as contributingmin(i_recv_data_rem, RDS_FRAG_SIZE)bytes, regardless of the completion length. When a completion is shorter than the header-declared amount, receive accounting can advance beyond the payload supplied by the completion.Only an
IB_WC_RECVcompletion has the buffer layout expected by this receive path. Other successful completion opcodes must not be interpreted as ordinary receive completions.Reject successful completions with any other opcode before processing their length. For ordinary receive completions, require enough payload to cover the amount accounted to the fragment before linking its page into the incoming message.
Quoted 6 lines
[ ... ]Fixes 1e23b3ee0e94 ("RDS/IB: Receive datagrams via IB")Assisted-by LLM (OpenAI Codex, gpt-5.6-sol)Signed-off-by Shubham Antil <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 22 lines · Shubham Antil
rds_ib_process_recv()accounts every receive fragment as contributingmin(i_recv_data_rem, RDS_FRAG_SIZE)bytes, regardless of the completion length. When a completion is shorter than the header-declared amount, receive accounting can advance beyond the payload supplied by the completion.Only an
IB_WC_RECVcompletion has the buffer layout expected by this receive path. Other successful completion opcodes must not be interpreted as ordinary receive completions.Reject successful completions with any other opcode before processing their length. For ordinary receive completions, require enough payload to cover the amount accounted to the fragment before linking its page into the incoming message.
This is compatible with the current transmit paths.
MSG_ZEROCOPYis restricted to RDS/TCP, while RDS/IB copied and page-vector messages use full-sized non-final scatterlist entries.Found during an LLM-assisted source audit and validated under KMSAN with a malformed short receive completion.
Quoted 12 lines
Reported-by sungbyeongchan <[email protected]>Reported-by Giovanni Vignone <[email protected]>Reported-by Robert van Eijk <[email protected]>Reported-by Paolo Gentry <[email protected]>Fixes 1e23b3ee0e94 ("RDS/IB: Receive datagrams via IB")Assisted-by LLM (OpenAI Codex, gpt-5.6-sol)Signed-off-by Shubham Antil <[email protected]>
Thanks Shubham,
This version looks good to me. I also tested it and found no regressions.
Thank you!
Allison
Quoted 48 lines
---
Changes in v4:
- Reject malformed short fragments instead of normalizing their length.
- Reject successful non-IB_WC_RECV completions before trustingbyte_len.
- Explain whyMSG_ZEROCOPYcannot reach the RDS/IB transmit path.
- Add the source-audit and KMSAN discovery details.
- Remove the author's self-Reported-by while retaining linked reporters.
- Leave maximumh_lenvalidation to a separate investigation.v3: https://lore.kernel.org/netdev/[email protected]/
v2: https://lore.kernel.org/netdev/[email protected]/net/rds/ib_recv.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)net/rds/ib_recv.c +12
-1@@ -949,6 +949,12 @@ static void rds_ib_process_recv(struct rds_connection *conn, } } +if (data_len <min_t (u32, ic->i_recv_data_rem,RDS_FRAG_SIZE )) { +rds_ib_conn_error (conn, +"fragment shorter than header-declared length; forcing reconnect\n" ); + goto done; + } +list_add_tail (&recv->r_frag->f_item, &ibinc->ii_frags); recv->r_frag =NULL ;@@ -1004,7 +1010,12 @@ void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic,* event is processed. */ if (wc->status ==IB_WC_SUCCESS ) { -rds_ib_process_recv (conn, recv, wc->byte_len, state); +if (wc->opcode !=IB_WC_RECV ) +rds_ib_conn_error (conn, +"recv completion had unexpected opcode %u, disconnecting and reconnecting\n" , + wc->opcode); +else +rds_ib_process_recv (conn, recv, wc->byte_len, state); }else {/* We expect errors as the qp is drained during shutdown */ if (rds_conn_up (conn) ||rds_conn_connecting (conn))base-commit:
72d3fcf802c45d00b300f25b848a93c3a2bd7c7e
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Tue, 13 Oct 2026 08:27:29 +0530 you wrote:
rds_ib_process_recv()accounts every receive fragment as contributingmin(i_recv_data_rem, RDS_FRAG_SIZE)bytes, regardless of the completion length. When a completion is shorter than the header-declared amount, receive accounting can advance beyond the payload supplied by the completion.Only an
IB_WC_RECVcompletion has the buffer layout expected by this receive path. Other successful completion opcodes must not be interpreted as ordinary receive completions.[...]
Here is the summary with links:
- [net,v4] RDS/IB: validate receive fragment completions
https://git.kernel.org/netdev/net/c/65cf6863606b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html