IB/core: Avoid a potential OOPs for an unused optional parameter
Subsystems (2)
PATCH 1/1 IB/core: Avoid a potential OOPs for an unused optional parameter
From: Michael J. Ruhl <[email protected]>
The ev_file is an optional parameter for CQ creation. If the parameter is not passed, the ev_file pointer will be NULL. Using that pointer to set the cq_context will result in an OOPs.
Verify that ev_file is not NULL before using.
Cc <[email protected]> # 4.14.x
Fixes 9ee79fce3642 ("IB/core: Add completion queue (cq) object actions")
Reviewed-by Dennis Dalessandro <[email protected]>
Reviewed-by Ira Weiny <[email protected]>
Signed-off-by Michael J. Ruhl <[email protected]>
Signed-off-by Dennis Dalessandro <[email protected]>
--- drivers/infiniband/core/uverbs_std_types.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/infiniband/core/uverbs_std_types.c +1 -1
@@ -316,7 +316,7 @@ static int uverbs_create_cq_handler(struct ib_device *ib_dev, cq->uobject = &obj->uobject; cq->comp_handler = ib_uverbs_comp_handler; cq->event_handler = ib_uverbs_cq_event_handler; - cq->cq_context = &ev_file->ev_queue; + cq->cq_context = ev_file ? &ev_file->ev_queue :NULL ; obj->uobject.object = cq; obj->uobject.user_handle = user_handle;atomic_set (&cq->usecnt,0 );
Quoted 8 lines · Dennis Dalessandro
From: Michael J. Ruhl <[email protected]>
The
ev_fileis an optional parameter for CQ creation. If the parameter is not passed, theev_filepointer will be NULL. Using that pointer to set thecq_contextwill result in an OOPs.Verify that
ev_fileis not NULL before using.
Quoted 8 lines
Cc <[email protected]> # 4.14.xFixes 9ee79fce3642 ("IB/core: Add completion queue (cq) object actions")Reviewed-by Dennis Dalessandro <[email protected]>Reviewed-by Ira Weiny <[email protected]>Signed-off-by Michael J. Ruhl <[email protected]>Signed-off-by Dennis Dalessandro <[email protected]>drivers/infiniband/core/uverbs_std_types.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Yep! I was testing this recently and didn't hit this bug, it only becomes a crash if something tries to use the cq..
Jason