Skip to content

Commit 7244491

Browse files
hkbinbinbinjgunthorpe
authored andcommitted
RDMA/rxe: Validate pad and ICRC before payload_size() in rxe_rcv
rxe_rcv() currently checks only that the incoming packet is at least header_size(pkt) bytes long before payload_size() is used. However, payload_size() subtracts both the attacker-controlled BTH pad field and RXE_ICRC_SIZE from pkt->paylen: payload_size = pkt->paylen - offset[RXE_PAYLOAD] - bth_pad(pkt) - RXE_ICRC_SIZE This means a short packet can still make payload_size() underflow even if it includes enough bytes for the fixed headers. Simply requiring header_size(pkt) + RXE_ICRC_SIZE is not sufficient either, because a packet with a forged non-zero BTH pad can still leave payload_size() negative and pass an underflowed value to later receive-path users. Fix this by validating pkt->paylen against the full minimum length required by payload_size(): header_size(pkt) + bth_pad(pkt) + RXE_ICRC_SIZE. Cc: [email protected] Fixes: 8700e3e ("Soft RoCE driver") Link: https://patch.msgid.link/r/[email protected] Signed-off-by: hkbinbin <[email protected]> Reviewed-by: Zhu Yanjun <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 6ed3d14 commit 7244491

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/infiniband/sw/rxe/rxe_recv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ void rxe_rcv(struct sk_buff *skb)
330330
pkt->qp = NULL;
331331
pkt->mask |= rxe_opcode[pkt->opcode].mask;
332332

333-
if (unlikely(skb->len < header_size(pkt)))
333+
if (unlikely(pkt->paylen < header_size(pkt) + bth_pad(pkt) +
334+
RXE_ICRC_SIZE))
334335
goto drop;
335336

336337
err = hdr_check(pkt);

0 commit comments

Comments
 (0)