]> git.baikalelectronics.ru Git - kernel.git/commit
IB/uverbs: Fix ordering of ucontext check in ib_uverbs_write
authorJason Gunthorpe <jgg@mellanox.com>
Tue, 12 Jun 2018 15:40:23 +0000 (09:40 -0600)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 12 Jun 2018 20:39:32 +0000 (14:39 -0600)
commitbb0e7257de4c490f315c467a3e850e31898dc142
tree027b021e6efb08f389e12e1bd7af94bfc7b3f323
parent6d16a9d8ca7cca333feb8379300dc7c52a8a3a5e
IB/uverbs: Fix ordering of ucontext check in ib_uverbs_write

During disassociation the ucontext will become NULL, however due to how
the SRCU locking works the ucontext must only be examined after looking
at the ib_dev, which governs the RCU control flow.

With the wrong ordering userspace will see EINVAL instead of EIO for a
disassociated uverbs FD, which breaks rdma-core.

Cc: stable@vger.kernel.org
Fixes: a1a9b4a69a26 ("RDMA/uverbs: Move uncontext check before SRCU read lock")
Reported-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
drivers/infiniband/core/uverbs_main.c