Received: by 10.192.165.148 with SMTP id m20csp556764imm; Wed, 25 Apr 2018 04:13:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/8KobWw8nOUOxnxV4PTXiHSQxcDVUkfEH424/lZ4IT7LSWYwFIcjjcrQblYYGfbflh0PZh X-Received: by 10.98.55.69 with SMTP id e66mr27525778pfa.253.1524654788470; Wed, 25 Apr 2018 04:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524654788; cv=none; d=google.com; s=arc-20160816; b=UV55TgBMKia6d67sCAonbSynknRS1QDz9gmMk1XXvx+f4en8ECWUqSLukjN7tUX1hp w5FtulpQgfURS63wCwEQ1D76DxMR28zfJpNXRySFySpW75m3hoMhOip4jmIehljS1VEY nUWe/S+C4Y9PFlFrOE432vc9qQUaGTaqs1Mhx7tavgSzbc0CUjHIbirkj+a7xNFD45Tk 3khJpDwyizo2nhoQi/El5ulzw74Q5516p1/7B2HYtSLfhEwKV0BIxfHkdzOhWVzd7Mbc 0AJHHeknLUnp/HSyVjNpa10GFIqBHsuM3H2uvpjp/cFSbv7gV6wlnGiTIdsVRxp6aoQj VMtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=DTSj1fZoAbGZu/zoqYGSmW5f6u0fJLt8WvclgQHkd7E=; b=RXl5GzXR74DSSNeT8EFiCQttLAFk815aK8L4bnfkhvCK0n3QfOZlhUMxA92SFWmWYc KLY3Xyjr6qAYT7x1skGWdERx/1EW8by1+fXFuscCVJl0aps1cw5eKPwwzsWMkwR9EPzp pdgUY7kMqS9agZ+hzCwv4lFvQeTWi4q+Dr4oQJK2DTKAuFz/fSQ5paQc8ra2HN9Pwl4r TkupOw5X1isuQbOShf9TE16Bcb1m4+JBQdvwfHCXGO3BSDPgLXSy/LohST+7VecpBNca BKsblZ3t3VSCmoV7rEZVmbTy13d3efFLdtqBQaBbSF8t+u7/0/lc1zC8vgzK8l4FEFqb 9i3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n30si13701826pgc.231.2018.04.25.04.12.54; Wed, 25 Apr 2018 04:13:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753451AbeDYLKs (ORCPT + 99 others); Wed, 25 Apr 2018 07:10:48 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52266 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753859AbeDYKlB (ORCPT ); Wed, 25 Apr 2018 06:41:01 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 338C536; Wed, 25 Apr 2018 10:41:01 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Parav Pandit , Mark Bloch , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.14 069/183] RDMA/cma: Check existence of netdevice during port validation Date: Wed, 25 Apr 2018 12:34:49 +0200 Message-Id: <20180425103245.294226572@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/cma.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -624,11 +624,13 @@ static inline int cma_validate_port(stru if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port)) return ret; - if (dev_type == ARPHRD_ETHER && rdma_protocol_roce(device, port)) + if (dev_type == ARPHRD_ETHER && rdma_protocol_roce(device, port)) { ndev = dev_get_by_index(&init_net, bound_if_index); - else + if (!ndev) + return ret; + } else { gid_type = IB_GID_TYPE_IB; - + } ret = ib_find_cached_gid_by_port(device, gid, gid_type, port, ndev, NULL);