Skip to content

Commit 3282a54

Browse files
ddmatsujgunthorpe
authored andcommitted
RDMA/rxe: Fix oops with zero length reads
The commit 686d348 ("RDMA/rxe: Remove unnecessary mr testing") causes a kernel crash. If responder get a zero-byte RDMA Read request, qp->resp.mr is not set in check_rkey() (see IBA C9-88). The mr is NULL in this case, and a NULL pointer dereference occurs as shown below. BUG: kernel NULL pointer dereference, address: 0000000000000010 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 0 P4D 0 Oops: 0002 [#1] PREEMPT SMP PTI CPU: 2 PID: 3622 Comm: python3 Kdump: loaded Not tainted 6.1.0-rc3+ #34 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 RIP: 0010:__rxe_put+0xc/0x60 [rdma_rxe] Code: cc cc cc 31 f6 e8 64 36 1b d3 41 b8 01 00 00 00 44 89 c0 c3 cc cc cc cc 41 89 c0 eb c1 90 0f 1f 44 00 00 41 54 b8 ff ff ff ff <f0> 0f c1 47 10 83 f8 01 74 11 45 31 e4 85 c0 7e 20 44 89 e0 41 5c RSP: 0018:ffffb27bc012ce78 EFLAGS: 00010246 RAX: 00000000ffffffff RBX: ffff9790857b0580 RCX: 0000000000000000 RDX: ffff979080fe145a RSI: 000055560e3e0000 RDI: 0000000000000000 RBP: ffff97909c7dd800 R08: 0000000000000001 R09: e7ce43d97f7bed0f R10: ffff97908b29c300 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: ffff97908b29c300 R15: 0000000000000000 FS: 00007f276f7bd740(0000) GS:ffff9792b5c80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000010 CR3: 0000000114230002 CR4: 0000000000060ee0 Call Trace: <IRQ> read_reply+0xda/0x310 [rdma_rxe] rxe_responder+0x82d/0xe50 [rdma_rxe] do_task+0x84/0x170 [rdma_rxe] tasklet_action_common.constprop.0+0xa7/0x120 __do_softirq+0xcb/0x2ac do_softirq+0x63/0x90 </IRQ> Support a NULL mr during read_reply() Fixes: 686d348 ("RDMA/rxe: Remove unnecessary mr testing") Fixes: b5f9a01 ("RDMA/rxe: Fix mr leak in RESPST_ERR_RNR") Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daisuke Matsuda <[email protected]> Signed-off-by: Li Zhijian <[email protected]> Reviewed-by: Li Zhijian <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent d69e8c6 commit 3282a54

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/infiniband/sw/rxe/rxe_resp.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ static enum resp_states check_rkey(struct rxe_qp *qp,
460460
return RESPST_EXECUTE;
461461
}
462462

463-
/* A zero-byte op is not required to set an addr or rkey. */
463+
/* A zero-byte op is not required to set an addr or rkey. See C9-88 */
464464
if ((pkt->mask & RXE_READ_OR_WRITE_MASK) &&
465465
(pkt->mask & RXE_RETH_MASK) &&
466466
reth_len(pkt) == 0) {
@@ -880,13 +880,15 @@ static enum resp_states read_reply(struct rxe_qp *qp,
880880
skb = prepare_ack_packet(qp, &ack_pkt, opcode, payload,
881881
res->cur_psn, AETH_ACK_UNLIMITED);
882882
if (!skb) {
883-
rxe_put(mr);
883+
if (mr)
884+
rxe_put(mr);
884885
return RESPST_ERR_RNR;
885886
}
886887

887888
err = rxe_mr_copy(mr, res->read.va, payload_addr(&ack_pkt),
888889
payload, RXE_FROM_MR_OBJ);
889-
rxe_put(mr);
890+
if (mr)
891+
rxe_put(mr);
890892
if (err) {
891893
kfree_skb(skb);
892894
return RESPST_ERR_RKEY_VIOLATION;

0 commit comments

Comments
 (0)