Message ID | 20230314134456.3557-2-n.zhandarovich@fintech.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1780573wrd; Tue, 14 Mar 2023 07:09:22 -0700 (PDT) X-Google-Smtp-Source: AK7set/qYY6FVTGJKlfM/rW/nfztGoBb8vPFVIhNxRSfcqWX73ZNQPBcy63zSO0ONRslzUqhVwhy X-Received: by 2002:a05:6e02:c66:b0:315:498b:4165 with SMTP id f6-20020a056e020c6600b00315498b4165mr2007420ilj.32.1678802962543; Tue, 14 Mar 2023 07:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678802962; cv=none; d=google.com; s=arc-20160816; b=tvhKqtffgUxHqah9V7jsbdVd/39W/rdMDDAagOFFo7iHE4dEETN9N8zKX93t/onope nAA9cRfKW12P8PHRh6lIDiV5MO2pngEIy989b7xQ5hiRJ548dBi7G5qqpstIOm7Zncna NijEu1jQJtDMJScq94i49YeSLsvtsoL8V+Pdtv621nNQPdFLdG4Gbkja1BUASmigytil LJ8bZ+7Dzz9n/tMZiwxDg5wFvrMfMfL23g46ER6xUYCsfke/uhqIRm/FyzlGUU1pREC9 2tjsN8yt5Dv19bpqjSQk2nxP3RJBYWGmMCvVawXasnu+FkUPuyHQkmEdXmZCE7YA7OaX mgbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Hz4+k7h4zCOH1B7KIziNGf5Xkq5I6RBB6aGSTXkJzyU=; b=mKEFddT7AGQksuSLl1qyqfqRTWbqowNzkD2cCERdFThJnZzK4JW4iCnl27rVOdCzwt STLJE6AxO0l9Wgrrnh64U6r06JGw8Lrs86BmoU/ri7n2TqSGQtZ3TTdThFG0Nf+d3KP6 hVyHgxO4nxXeDxHiLtQMSiWOVsX6xZoiSEo8rQZZZfLIi0ANzHSEqGHPrppzoCHgHINC kkKViGYjd1wOO/7qrNNx2dcdaxGRWQeLZJYF9OTOeNa6nBtMW/4Dc7glep8LPSyoEmVk rJoKS83W+sCYq7Wb588QgXXYyVrytQVpFhWTBX2cMUJZNfjzdeN+Ff+01E+UlrOaP7zB GKRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t14-20020a922c0e000000b0031799f1b52bsi2330103ile.164.2023.03.14.07.09.05; Tue, 14 Mar 2023 07:09:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231260AbjCNNtH (ORCPT <rfc822;realc9580@gmail.com> + 99 others); Tue, 14 Mar 2023 09:49:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231231AbjCNNsc (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Mar 2023 09:48:32 -0400 Received: from exchange.fintech.ru (e10edge.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FEFD9F061; Tue, 14 Mar 2023 06:45:31 -0700 (PDT) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 14 Mar 2023 16:45:25 +0300 Received: from localhost (10.0.253.157) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 14 Mar 2023 16:45:25 +0300 From: Nikita Zhandarovich <n.zhandarovich@fintech.ru> To: <stable@vger.kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org> CC: Nikita Zhandarovich <n.zhandarovich@fintech.ru>, Mustafa Ismail <mustafa.ismail@intel.com>, Shiraz Saleem <shiraz.saleem@intel.com>, "Jason Gunthorpe" <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>, <linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <lvc-project@linuxtesting.org> Subject: [PATCH 5.4/5.10 1/1] RDMA/i40iw: Fix potential NULL-ptr-dereference Date: Tue, 14 Mar 2023 06:44:56 -0700 Message-ID: <20230314134456.3557-2-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230314134456.3557-1-n.zhandarovich@fintech.ru> References: <20230314134456.3557-1-n.zhandarovich@fintech.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.253.157] X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760352495331050482?= X-GMAIL-MSGID: =?utf-8?q?1760352495331050482?= |
Series |
RDMA/i40iw: Fix potential NULL-ptr-dereference
|
|
Commit Message
Nikita Zhandarovich
March 14, 2023, 1:44 p.m. UTC
From: Nikita Zhandarovich <n.zhandarovich@fintech.ru> commit 5d9745cead1f121974322b94ceadfb4d1e67960e upstream. in_dev_get() can return NULL which will cause a failure once idev is dereferenced in in_dev_for_each_ifa_rtnl(). This patch adds a check for NULL value in idev beforehand. Found by Linux Verification Center (linuxtesting.org) with SVACE. Changes made to the original patch during backporting: Apply patch to drivers/infiniband/hw/i40iw/i40iw_cm.c instead of drivers/infiniband/hw/irdma/cm.c due to the fact that kernel versions 5.10 and below use i40iw driver, not irdma. Fixes: f27b4746f378 ("i40iw: add connection management code") Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru> Link: https://lore.kernel.org/r/20230126185230.62464-1-n.zhandarovich@fintech.ru --- drivers/infiniband/hw/i40iw/i40iw_cm.c | 2 ++ 1 file changed, 2 insertions(+)
Comments
On Tue, Mar 14, 2023 at 06:44:56AM -0700, Nikita Zhandarovich wrote: > From: Nikita Zhandarovich <n.zhandarovich@fintech.ru> > > commit 5d9745cead1f121974322b94ceadfb4d1e67960e upstream. > > in_dev_get() can return NULL which will cause a failure once idev is > dereferenced in in_dev_for_each_ifa_rtnl(). This patch adds a > check for NULL value in idev beforehand. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Changes made to the original patch during backporting: > Apply patch to drivers/infiniband/hw/i40iw/i40iw_cm.c instead of > drivers/infiniband/hw/irdma/cm.c due to the fact that kernel versions > 5.10 and below use i40iw driver, not irdma. > > Fixes: f27b4746f378 ("i40iw: add connection management code") > Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru> > Link: https://lore.kernel.org/r/20230126185230.62464-1-n.zhandarovich@fintech.ru > --- > drivers/infiniband/hw/i40iw/i40iw_cm.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/infiniband/hw/i40iw/i40iw_cm.c b/drivers/infiniband/hw/i40iw/i40iw_cm.c > index 3053c345a5a3..e1236ac502f2 100644 > --- a/drivers/infiniband/hw/i40iw/i40iw_cm.c > +++ b/drivers/infiniband/hw/i40iw/i40iw_cm.c > @@ -1776,6 +1776,8 @@ static enum i40iw_status_code i40iw_add_mqh_4( > const struct in_ifaddr *ifa; > > idev = in_dev_get(dev); > + if (!idev) > + continue; > > in_dev_for_each_ifa_rtnl(ifa, idev) { > i40iw_debug(&iwdev->sc_dev, As this isn't anything that can be triggered by a normal system operation, I'm going to drop it from the review queue. Unless you have a reproducer that can cause this to happen from userspace? thanks, greg k-h
On 3/15/23 01:00, Greg Kroah-Hartman wrote: > On Tue, Mar 14, 2023 at 06:44:56AM -0700, Nikita Zhandarovich wrote: >> From: Nikita Zhandarovich <n.zhandarovich@fintech.ru> >> >> commit 5d9745cead1f121974322b94ceadfb4d1e67960e upstream. >> >> in_dev_get() can return NULL which will cause a failure once idev is >> dereferenced in in_dev_for_each_ifa_rtnl(). This patch adds a >> check for NULL value in idev beforehand. >> >> Found by Linux Verification Center (linuxtesting.org) with SVACE. >> >> Changes made to the original patch during backporting: >> Apply patch to drivers/infiniband/hw/i40iw/i40iw_cm.c instead of >> drivers/infiniband/hw/irdma/cm.c due to the fact that kernel versions >> 5.10 and below use i40iw driver, not irdma. >> >> Fixes: f27b4746f378 ("i40iw: add connection management code") >> Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru> >> Link: https://lore.kernel.org/r/20230126185230.62464-1-n.zhandarovich@fintech.ru >> --- >> drivers/infiniband/hw/i40iw/i40iw_cm.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/drivers/infiniband/hw/i40iw/i40iw_cm.c b/drivers/infiniband/hw/i40iw/i40iw_cm.c >> index 3053c345a5a3..e1236ac502f2 100644 >> --- a/drivers/infiniband/hw/i40iw/i40iw_cm.c >> +++ b/drivers/infiniband/hw/i40iw/i40iw_cm.c >> @@ -1776,6 +1776,8 @@ static enum i40iw_status_code i40iw_add_mqh_4( >> const struct in_ifaddr *ifa; >> >> idev = in_dev_get(dev); >> + if (!idev) >> + continue; >> >> in_dev_for_each_ifa_rtnl(ifa, idev) { >> i40iw_debug(&iwdev->sc_dev, > > As this isn't anything that can be triggered by a normal system > operation, I'm going to drop it from the review queue. Unless you have > a reproducer that can cause this to happen from userspace? > > thanks, > > greg k-h Currently working on seeing whether a reproducer is feasible. It makes sense to not include the patch until then. thanks for your time, Nikita
diff --git a/drivers/infiniband/hw/i40iw/i40iw_cm.c b/drivers/infiniband/hw/i40iw/i40iw_cm.c index 3053c345a5a3..e1236ac502f2 100644 --- a/drivers/infiniband/hw/i40iw/i40iw_cm.c +++ b/drivers/infiniband/hw/i40iw/i40iw_cm.c @@ -1776,6 +1776,8 @@ static enum i40iw_status_code i40iw_add_mqh_4( const struct in_ifaddr *ifa; idev = in_dev_get(dev); + if (!idev) + continue; in_dev_for_each_ifa_rtnl(ifa, idev) { i40iw_debug(&iwdev->sc_dev,