Skip to content

Commit 1b2fe85

Browse files
zhijianli88jgunthorpe
authored andcommitted
RDMA/rxe: Fix null pointer dereference in ODP MR check
The blktests/rnbd reported a null pointer dereference as following. Similar to the mlx5, introduce a is_odp_mr() to check if the odp is enabled in this mr. Workqueue: rxe_wq do_work [rdma_rxe] RIP: 0010:rxe_mr_copy+0x57/0x210 [rdma_rxe] Code: 7c 04 48 89 f3 48 89 d5 41 89 cf 45 89 c4 0f 84 dc 00 00 00 89 ca e8 f8 f8 ff ff 85 c0 0f 85 75 01 00 00 49 8b 86 f0 00 00 00 <f6> 40 28 02 0f 85 98 01 00 00 41 8b 46 78 41 8b 8e 10 01 00 00 8d RSP: 0018:ffffa0aac02cfcf8 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff9079cd440024 RCX: 0000000000000000 RDX: 000000000000003c RSI: ffff9079cd440060 RDI: ffff9079cd665600 RBP: ffff9079c0e5e45a R08: 0000000000000000 R09: 0000000000000000 R10: 000000003c000000 R11: 0000000000225510 R12: 0000000000000000 R13: 0000000000000000 R14: ffff9079cd665600 R15: 000000000000003c FS: 0000000000000000(0000) GS:ffff907ccfa80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000028 CR3: 0000000119498001 CR4: 00000000001726f0 Call Trace: <TASK> ? __die_body+0x1e/0x60 ? page_fault_oops+0x14f/0x4c0 ? rxe_mr_copy+0x57/0x210 [rdma_rxe] ? search_bpf_extables+0x5f/0x80 ? exc_page_fault+0x7e/0x180 ? asm_exc_page_fault+0x26/0x30 ? rxe_mr_copy+0x57/0x210 [rdma_rxe] ? rxe_mr_copy+0x48/0x210 [rdma_rxe] ? rxe_pool_get_index+0x50/0x90 [rdma_rxe] rxe_receiver+0x1d98/0x2530 [rdma_rxe] ? psi_task_switch+0x1ff/0x250 ? finish_task_switch+0x92/0x2d0 ? __schedule+0xbdf/0x17c0 do_task+0x65/0x1e0 [rdma_rxe] process_scheduled_works+0xaa/0x3f0 worker_thread+0x117/0x240 Fixes: d03fb5c ("RDMA/rxe: Allow registering MRs for On-Demand Paging") Cc: stable@vger.kernel.org Link: https://patch.msgid.link/r/20250402032657.1762800-1-lizhijian@fujitsu.com Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> Reviewed-by: Daisuke Matsuda <matsuda-daisuke@fujitsu.com> Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent d247667 commit 1b2fe85

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

drivers/infiniband/sw/rxe/rxe_loc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ static inline int qp_mtu(struct rxe_qp *qp)
140140
return IB_MTU_4096;
141141
}
142142

143+
static inline bool is_odp_mr(struct rxe_mr *mr)
144+
{
145+
return IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING) && mr->umem &&
146+
mr->umem->is_odp;
147+
}
148+
143149
void free_rd_atomic_resource(struct resp_res *res);
144150

145151
static inline void rxe_advance_resp_resource(struct rxe_qp *qp)

drivers/infiniband/sw/rxe/rxe_mr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr,
323323
return err;
324324
}
325325

326-
if (mr->umem->is_odp)
326+
if (is_odp_mr(mr))
327327
return rxe_odp_mr_copy(mr, iova, addr, length, dir);
328328
else
329329
return rxe_mr_copy_xarray(mr, iova, addr, length, dir);
@@ -536,7 +536,7 @@ int rxe_mr_do_atomic_write(struct rxe_mr *mr, u64 iova, u64 value)
536536
u64 *va;
537537

538538
/* ODP is not supported right now. WIP. */
539-
if (mr->umem->is_odp)
539+
if (is_odp_mr(mr))
540540
return RESPST_ERR_UNSUPPORTED_OPCODE;
541541

542542
/* See IBA oA19-28 */

drivers/infiniband/sw/rxe/rxe_resp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ static enum resp_states process_flush(struct rxe_qp *qp,
650650
struct resp_res *res = qp->resp.res;
651651

652652
/* ODP is not supported right now. WIP. */
653-
if (mr->umem->is_odp)
653+
if (is_odp_mr(mr))
654654
return RESPST_ERR_UNSUPPORTED_OPCODE;
655655

656656
/* oA19-14, oA19-15 */
@@ -706,7 +706,7 @@ static enum resp_states atomic_reply(struct rxe_qp *qp,
706706
if (!res->replay) {
707707
u64 iova = qp->resp.va + qp->resp.offset;
708708

709-
if (mr->umem->is_odp)
709+
if (is_odp_mr(mr))
710710
err = rxe_odp_atomic_op(mr, iova, pkt->opcode,
711711
atmeth_comp(pkt),
712712
atmeth_swap_add(pkt),

0 commit comments

Comments
 (0)