IB/core: Verify that QP is security enabled in create and destroy
authorMoni Shoua <monis@mellanox.com>
Sun, 24 Dec 2017 11:54:58 +0000 (13:54 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Wed, 27 Dec 2017 22:24:41 +0000 (15:24 -0700)
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: <stable@vger.kernel.org> # v4.12
Fixes: d291f1a65232 ("IB/core: Enforce PKey security on QPs")
Reviewed-by: Daniel Jurgens <danielj@mellanox.com>
Signed-off-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

index feafdb9..59b2f96 100644 (file)
@@ -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;
        ret = check_qp_port_pkey_settings(real_qp->qp_sec->ports_pkeys,
index 3fb8fb6..e36d27e 100644 (file)
@@ -1438,7 +1438,8 @@ int ib_close_qp(struct ib_qp *qp)
        spin_unlock_irqrestore(&real_qp->device->event_handler_lock, flags);
-       ib_close_shared_qp_security(qp->qp_sec);
+       if (qp->qp_sec)
+               ib_close_shared_qp_security(qp->qp_sec);
        return 0;