Skip to content

Commit 105bf79

Browse files
mjbommargregkh
authored andcommitted
RDMA/rxe: Reject non-8-byte ATOMIC_WRITE payloads
commit 1114c87 upstream. atomic_write_reply() at drivers/infiniband/sw/rxe/rxe_resp.c unconditionally dereferences 8 bytes at payload_addr(pkt): value = *(u64 *)payload_addr(pkt); check_rkey() previously accepted an ATOMIC_WRITE request with pktlen == resid == 0 because the length validation only compared pktlen against resid. A remote initiator that sets the RETH length to 0 therefore reaches atomic_write_reply() with a zero-byte logical payload, and the responder reads sizeof(u64) bytes from past the logical end of the packet into skb->head tailroom, then writes those 8 bytes into the attacker's MR via rxe_mr_do_atomic_write(). That is a remote disclosure of 4 bytes of kernel tailroom per probe (the other 4 bytes are the packet's own trailing ICRC). IBA oA19-28 defines ATOMIC_WRITE as exactly 8 bytes. Anything else is protocol-invalid. Hoist a strict length check into check_rkey() so the responder never reaches the unchecked dereference, and keep the existing WRITE-family length logic for the normal RDMA WRITE path. Reproduced on mainline with an unmodified rxe driver: a sustained zero-length ATOMIC_WRITE probe repeatedly leaks adjacent skb head-buffer bytes into the attacker's MR, including recognisable kernel strings and partial kernel-direct-map pointer words. With this patch applied the responder rejects the PDU and the MR stays all-zero. Cc: stable@vger.kernel.org Fixes: 034e285 ("RDMA/rxe: Make responder support atomic write on RC service") Link: https://patch.msgid.link/r/20260418162141.3610201-1-michael.bommarito@gmail.com Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com> Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8832626 commit 105bf79

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

drivers/infiniband/sw/rxe/rxe_resp.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,19 @@ static enum resp_states check_rkey(struct rxe_qp *qp,
526526
}
527527

528528
skip_check_range:
529-
if (pkt->mask & (RXE_WRITE_MASK | RXE_ATOMIC_WRITE_MASK)) {
529+
if (pkt->mask & RXE_ATOMIC_WRITE_MASK) {
530+
/* IBA oA19-28: ATOMIC_WRITE payload is exactly 8 bytes.
531+
* Reject any other length before the responder reads
532+
* sizeof(u64) bytes from payload_addr(pkt); a shorter
533+
* payload would read past the logical end of the packet
534+
* into skb->head tailroom.
535+
*/
536+
if (resid != sizeof(u64) || pktlen != sizeof(u64) ||
537+
bth_pad(pkt)) {
538+
state = RESPST_ERR_LENGTH;
539+
goto err;
540+
}
541+
} else if (pkt->mask & RXE_WRITE_MASK) {
530542
if (resid > mtu) {
531543
if (pktlen != mtu || bth_pad(pkt)) {
532544
state = RESPST_ERR_LENGTH;

0 commit comments

Comments
 (0)