From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-co1nam03on0131.outbound.protection.outlook.com ([104.47.40.131]:30557 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753638AbeDIASf (ORCPT ); Sun, 8 Apr 2018 20:18:35 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Parav Pandit , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 067/189] RDMA/cma: Check existence of netdevice during port validation Date: Mon, 9 Apr 2018 00:17:37 +0000 Message-ID: <20180409001637.162453-67-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Parav Pandit [ Upstream commit 00db63c128dd3daf38f481371976c24d32678142 ] If valid netdevice is not found for RoCE, GID table should not be searched with NULL netdevice. Doing so causes the search routines to ignore the netdev argument and may match the wrong GID table entry if the netdev is deleted. Fixes: abae1b71dd37 ("IB/cma: cma_validate_port should verify the port and = netdevice") Signed-off-by: Parav Pandit Reviewed-by: Mark Bloch Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/cma.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 67aece2f5d8d..6958df862591 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -624,11 +624,13 @@ static inline int cma_validate_port(struct ib_device = *device, u8 port, if ((dev_type !=3D ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port)) return ret; =20 - if (dev_type =3D=3D ARPHRD_ETHER && rdma_protocol_roce(device, port)) + if (dev_type =3D=3D ARPHRD_ETHER && rdma_protocol_roce(device, port)) { ndev =3D dev_get_by_index(&init_net, bound_if_index); - else + if (!ndev) + return ret; + } else { gid_type =3D IB_GID_TYPE_IB; - + } =20 ret =3D ib_find_cached_gid_by_port(device, gid, gid_type, port, ndev, NULL); --=20 2.15.1