RDMA/mad: Reject receive completions shorter than GRH
PATCH 1/1 RDMA/mad: Reject receive completions shorter than GRH
ib_mad_recv_done() derives the OPA MAD length by subtracting the GRH size from wc->byte_len without ensuring the receive completion covers the GRH. If it is shorter, the subtraction wraps before the result is stored in mad_len and an invalid length can be passed downstream.
Reject receive completions shorter than the GRH before inspecting the MAD header or deriving the MAD length.
--- drivers/infiniband/core/mad.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/core/mad.c +2 -0
@@ -2342,6 +2342,8 @@ static void ib_mad_recv_done(struct ib_cq *cq, struct ib_wc *wc) recv->header.mapping,mad_priv_dma_size (recv), DMA_FROM_DEVICE); +if (unlikely (wc->byte_len <sizeof (struct ib_grh ))) + goto out;/* Setup MAD receive work completion from "normal" work completion */ recv->header.wc = *wc;
Signature · 1 line
2.34.1
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
ib_mad_recv_done()derives the OPA MAD length by subtracting the GRH size fromwc->byte_lenwithout ensuring the receive completion covers the GRH. If it is shorter, the subtraction wraps before the result is stored inmad_lenand an invalid length can be passed downstream.Reject receive completions shorter than the GRH before inspecting the MAD header or deriving the MAD length.
Fixes 8e4349d13f33 ("IB/mad: Add final OPA MAD processing")Signed-off-by Jiale Yao <[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
Leon Romanovsky
AppliedQuoted 9 lines · Jiale Yao
ib_mad_recv_done()derives the OPA MAD length by subtracting the GRH size fromwc->byte_lenwithout ensuring the receive completion covers the GRH. If it is shorter, the subtraction wraps before the result is stored inmad_lenand an invalid length can be passed downstream.Reject receive completions shorter than the GRH before inspecting the MAD header or deriving the MAD length.
[...]
Applied, thanks!
[1/1] RDMA/mad: Reject receive completions shorter than GRH
https://git.kernel.org/rdma/rdma/c/2dc2126e690203
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>