Skip to content

Commit

Permalink
IB/iser: Fix possible NULL deref at iser_inv_desc()
Browse files Browse the repository at this point in the history
In case target remote invalidates bogus rkey and signature is not used,
pi_ctx is NULL deref.

The commit also fails the connection on bogus remote invalidation.

Fixes: 59caaed ("IB/iser: Support the remote invalidation exception")
Signed-off-by: Israel Rukshin <israelr@mellanox.com>
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Israel Rukshin authored and Jason Gunthorpe committed Sep 28, 2018
1 parent 3df6e02 commit 65f07f5
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions drivers/infiniband/ulp/iser/iser_initiator.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,13 +589,19 @@ void iser_login_rsp(struct ib_cq *cq, struct ib_wc *wc)
ib_conn->post_recv_buf_count--;
}

static inline void
static inline int
iser_inv_desc(struct iser_fr_desc *desc, u32 rkey)
{
if (likely(rkey == desc->rsc.mr->rkey))
if (likely(rkey == desc->rsc.mr->rkey)) {
desc->rsc.mr_valid = 0;
else if (likely(rkey == desc->pi_ctx->sig_mr->rkey))
} else if (likely(desc->pi_ctx && rkey == desc->pi_ctx->sig_mr->rkey)) {
desc->pi_ctx->sig_mr_valid = 0;
} else {
iser_err("Bogus remote invalidation for rkey %#x\n", rkey);
return -EINVAL;
}

return 0;
}

static int
Expand Down Expand Up @@ -623,12 +629,14 @@ iser_check_remote_inv(struct iser_conn *iser_conn,

if (iser_task->dir[ISER_DIR_IN]) {
desc = iser_task->rdma_reg[ISER_DIR_IN].mem_h;
iser_inv_desc(desc, rkey);
if (unlikely(iser_inv_desc(desc, rkey)))
return -EINVAL;
}

if (iser_task->dir[ISER_DIR_OUT]) {
desc = iser_task->rdma_reg[ISER_DIR_OUT].mem_h;
iser_inv_desc(desc, rkey);
if (unlikely(iser_inv_desc(desc, rkey)))
return -EINVAL;
}
} else {
iser_err("failed to get task for itt=%d\n", hdr->itt);
Expand Down

0 comments on commit 65f07f5

Please sign in to comment.