* [PATCH] RDMA/siw: Bound fragmented header copies by the remaining length
@ 2026-09-08 8:55 Jérémy Jean
2026-09-08 13:12 ` Bernard Metzler
2026-09-10 15:15 ` Leon Romanovsky
0 siblings, 2 replies; 3+ messages in thread
From: Jérémy Jean @ 2026-09-08 8:55 UTC (permalink / raw)
To: bernard.metzler
Cc: jgg, leonro, linux-rdma, linux-kernel, Jérémy Jean
siw_get_hdr() can receive an extended DDP/RDMAP header across more than
one TCP callback. The first callback may receive most of the header,
while the next one still limits the copy to hdrlen - MIN_DDP_HDR instead
of the number of missing bytes. This makes the destination move past the
end of the header and overwrite the receive state, including
fpdu_part_rcvd. A later callback can then use a negative fpdu_part_rcvd
value as a copy offset, which creates an OOB write.
Use the number of header bytes already received when calculating the
next copy length.
Fixes: 754209850df8 ("RDMA/siw: Always consume all skbuf data in sk_data_ready() upcall.")
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
Assisted-by: Codex:gpt-6
---
drivers/infiniband/sw/siw/siw_qp_rx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c b/drivers/infiniband/sw/siw/siw_qp_rx.c
index b566d16..e5b641c 100644
--- a/drivers/infiniband/sw/siw/siw_qp_rx.c
+++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
@@ -1079,7 +1079,7 @@ static int siw_get_hdr(struct siw_rx_stream *srx)
if (iwarp_pktinfo[opcode].hdr_len > sizeof(struct iwarp_ctrl_tagged)) {
int hdrlen = iwarp_pktinfo[opcode].hdr_len;
- bytes = min_t(int, hdrlen - MIN_DDP_HDR, srx->skb_new);
+ bytes = min_t(int, hdrlen - srx->fpdu_part_rcvd, srx->skb_new);
skb_copy_bits(skb, srx->skb_offset,
(char *)c_hdr + srx->fpdu_part_rcvd, bytes);
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] RDMA/siw: Bound fragmented header copies by the remaining length
2026-09-08 8:55 [PATCH] RDMA/siw: Bound fragmented header copies by the remaining length Jérémy Jean
@ 2026-09-08 13:12 ` Bernard Metzler
2026-09-10 15:15 ` Leon Romanovsky
1 sibling, 0 replies; 3+ messages in thread
From: Bernard Metzler @ 2026-09-08 13:12 UTC (permalink / raw)
To: Jérémy Jean; +Cc: jgg, leonro, linux-rdma, linux-kernel
On 08.09.2026 10:55, Jérémy Jean wrote:
> siw_get_hdr() can receive an extended DDP/RDMAP header across more than
> one TCP callback. The first callback may receive most of the header,
> while the next one still limits the copy to hdrlen - MIN_DDP_HDR instead
> of the number of missing bytes. This makes the destination move past the
> end of the header and overwrite the receive state, including
> fpdu_part_rcvd. A later callback can then use a negative fpdu_part_rcvd
> value as a copy offset, which creates an OOB write.
>
Excellent finding, thank you! That must trickle down to older stable.
> Use the number of header bytes already received when calculating the
> next copy length.
>
> Fixes: 754209850df8 ("RDMA/siw: Always consume all skbuf data in sk_data_ready() upcall.")
> Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> Assisted-by: Codex:gpt-6
> ---
> drivers/infiniband/sw/siw/siw_qp_rx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c b/drivers/infiniband/sw/siw/siw_qp_rx.c
> index b566d16..e5b641c 100644
> --- a/drivers/infiniband/sw/siw/siw_qp_rx.c
> +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
> @@ -1079,7 +1079,7 @@ static int siw_get_hdr(struct siw_rx_stream *srx)
> if (iwarp_pktinfo[opcode].hdr_len > sizeof(struct iwarp_ctrl_tagged)) {
> int hdrlen = iwarp_pktinfo[opcode].hdr_len;
>
> - bytes = min_t(int, hdrlen - MIN_DDP_HDR, srx->skb_new);
> + bytes = min_t(int, hdrlen - srx->fpdu_part_rcvd, srx->skb_new);
>
> skb_copy_bits(skb, srx->skb_offset,
> (char *)c_hdr + srx->fpdu_part_rcvd, bytes);
Acked-by: Bernard Metzler <bernard.metzler@linux.dev>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] RDMA/siw: Bound fragmented header copies by the remaining length
2026-09-08 8:55 [PATCH] RDMA/siw: Bound fragmented header copies by the remaining length Jérémy Jean
2026-09-08 13:12 ` Bernard Metzler
@ 2026-09-10 15:15 ` Leon Romanovsky
1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2026-09-10 15:15 UTC (permalink / raw)
To: bernard.metzler, Jérémy Jean
Cc: linux-rdma, linux-kernel, Jason Gunthorpe, Leon Romanovsky
On Tue, 08 Sep 2026 08:55:20 +0000, Jérémy Jean wrote:
> siw_get_hdr() can receive an extended DDP/RDMAP header across more than
> one TCP callback. The first callback may receive most of the header,
> while the next one still limits the copy to hdrlen - MIN_DDP_HDR instead
> of the number of missing bytes. This makes the destination move past the
> end of the header and overwrite the receive state, including
> fpdu_part_rcvd. A later callback can then use a negative fpdu_part_rcvd
> value as a copy offset, which creates an OOB write.
>
> [...]
Applied, thanks!
[1/1] RDMA/siw: Bound fragmented header copies by the remaining length
https://git.kernel.org/rdma/rdma/c/9ff797e516dbc1
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-10 15:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-08 8:55 [PATCH] RDMA/siw: Bound fragmented header copies by the remaining length Jérémy Jean
2026-09-08 13:12 ` Bernard Metzler
2026-09-10 15:15 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®