RDMA/mlx5: Fix multiple NULL-ptr deref errors in rereg_mr flow
authorLeon Romanovsky <leonro@mellanox.com>
Mon, 23 Apr 2018 14:01:52 +0000 (17:01 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 May 2018 07:51:52 +0000 (09:51 +0200)
commitbe855252ebce0d4402fd7abccf58806f12947b64
treed0dd9e0556ebdd5786641f06a245ba9ef69d8f5a
parent3ae1bf3681352fc8c08cbd3be2d210f59d4cc42a
RDMA/mlx5: Fix multiple NULL-ptr deref errors in rereg_mr flow

commit b4bd701ac469075d94ed9699a28755f2862252b9 upstream.

Failure in rereg MR releases UMEM but leaves the MR to be destroyed
by the user. As a result the following scenario may happen:
"create MR -> rereg MR with failure -> call to rereg MR again" and
hit "NULL-ptr deref or user memory access" errors.

Ensure that rereg MR is only performed on a non-dead MR.

Cc: syzkaller <syzkaller@googlegroups.com>
Cc: <stable@vger.kernel.org> # 4.5
Fixes: 395a8e4c32ea ("IB/mlx5: Refactoring register MR code")
Reported-by: Noa Osherovich <noaos@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/hw/mlx5/mr.c