Skip to content

Commit

Permalink
IB/core: Verify that QP is security enabled in create and destroy
Browse files Browse the repository at this point in the history
The XRC target QP create flow sets up qp_sec only if there is an IB link with
LSM security enabled. However, several other related uAPI entry points blindly
follow the qp_sec NULL pointer, resulting in a possible oops.

Check for NULL before using qp_sec.

Cc: <[email protected]> # v4.12
Fixes: d291f1a ("IB/core: Enforce PKey security on QPs")
Reviewed-by: Daniel Jurgens <[email protected]>
Signed-off-by: Moni Shoua <[email protected]>
Signed-off-by: Leon Romanovsky <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
  • Loading branch information
monis410 authored and jgunthorpe committed Dec 27, 2017
1 parent 05d14e7 commit 4a50881
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions drivers/infiniband/core/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ int ib_open_shared_qp_security(struct ib_qp *qp, struct ib_device *dev)
if (ret)
return ret;

if (!qp->qp_sec)
return 0;

mutex_lock(&real_qp->qp_sec->mutex);
ret = check_qp_port_pkey_settings(real_qp->qp_sec->ports_pkeys,
qp->qp_sec);
Expand Down
3 changes: 2 additions & 1 deletion drivers/infiniband/core/verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,8 @@ int ib_close_qp(struct ib_qp *qp)
spin_unlock_irqrestore(&real_qp->device->event_handler_lock, flags);

atomic_dec(&real_qp->usecnt);
ib_close_shared_qp_security(qp->qp_sec);
if (qp->qp_sec)
ib_close_shared_qp_security(qp->qp_sec);
kfree(qp);

return 0;
Expand Down

0 comments on commit 4a50881

Please sign in to comment.