IB/mlx4: Test port number before querying type.
authorTarick Bedeir <tarick@google.com>
Mon, 2 Jul 2018 21:02:34 +0000 (14:02 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Oct 2018 00:00:48 +0000 (17:00 -0700)
commit333cb98f393ba2edd0e2f8577d823c0ffd9fef4b
tree4af2686baa5feed1d81d4db9640e3ad5ff99fdfe
parent1f94cf4c81cb0c654cb8d0710e4a5ddb60ae7a45
IB/mlx4: Test port number before querying type.

[ Upstream commit f1228867adaf8890826f2b59e4caddb1c5cc2df7 ]

rdma_ah_find_type() can reach into ib_device->port_immutable with a
potentially out-of-bounds port number, so check that the port number is
valid first.

Fixes: 44c58487d51a ("IB/core: Define 'ib' and 'roce' rdma_ah_attr types")
Signed-off-by: Tarick Bedeir <tarick@google.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/hw/mlx4/qp.c