]> Git Repo - linux.git/commitdiff
IB/core: Fix XRC race condition in ib_uverbs_open_qp
authorJack Morgenstein <[email protected]>
Tue, 23 Sep 2014 09:38:26 +0000 (12:38 +0300)
committerRoland Dreier <[email protected]>
Tue, 14 Oct 2014 07:30:56 +0000 (00:30 -0700)
In ib_uverbs_open_qp, the sharable xrc target qp is created as a
"pseudo" qp and added to a list of qp's sharing the same physical
QP.  This is done before the "pseudo" qp is assigned a uobject.

There is a race condition here if an async event arrives at the
physical qp.  If the event is handled after the pseudo qp is added to
the list, but before it is assigned a uobject, the kernel crashes in
ib_uverbs_qp_event_handler, due to trying to dereference a NULL
uobject pointer.

Note that simply checking for non-NULL is not enough, due to error
flows in ib_uverbs_open_qp.  If the failure is after assigning the
uobject, but before the qp has fully been created, we still have a
problem.

Thus, in ib_uverbs_qp_event_handler, we test that the uobject is
present, and also that it is live.

Reported-by: Matthew Finlay <[email protected]>
Signed-off-by: Jack Morgenstein <[email protected]>
Signed-off-by: Or Gerlitz <[email protected]>
Signed-off-by: Roland Dreier <[email protected]>
drivers/infiniband/core/uverbs_main.c

index c73b22a257fe3c92c9398e5318acbc4ffa569b90..bb6fea12ce31b97ae549338a097e0a2302fd441c 100644 (file)
@@ -502,6 +502,10 @@ void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr)
 {
        struct ib_uevent_object *uobj;
 
+       /* for XRC target qp's, check that qp is live */
+       if (!event->element.qp->uobject || !event->element.qp->uobject->live)
+               return;
+
        uobj = container_of(event->element.qp->uobject,
                            struct ib_uevent_object, uobject);
 
This page took 0.059873 seconds and 4 git commands to generate.