RDMA/ucma: Don't allow setting RDMA_OPTION_IB_PATH without an RDMA device
authorRoland Dreier <roland@purestorage.com>
Tue, 3 Apr 2018 22:33:01 +0000 (15:33 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Apr 2018 07:36:31 +0000 (09:36 +0200)
commitb140d94688707e42b75cad3b020563a706101abe
tree45f98c8806b787591d99dec0430dddafdc19c8f9
parent79fbd052ea63e26ee739dbdd32b45bf124eb7923
RDMA/ucma: Don't allow setting RDMA_OPTION_IB_PATH without an RDMA device

commit 8435168d50e66fa5eae01852769d20a36f9e5e83 upstream.

Check to make sure that ctx->cm_id->device is set before we use it.
Otherwise userspace can trigger a NULL dereference by doing
RDMA_USER_CM_CMD_SET_OPTION on an ID that is not bound to a device.

Cc: <stable@vger.kernel.org>
Reported-by: <syzbot+a67bc93e14682d92fc2f@syzkaller.appspotmail.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/core/ucma.c