Message ID | 20230201090610.52782-1-n.petrova@fintech.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp166113wrn; Wed, 1 Feb 2023 01:08:32 -0800 (PST) X-Google-Smtp-Source: AK7set/Nx/7dCLM41SZ3ECGumLfZOl/pfc50VbmpD+HXt6Fb6kr9UUyDuwtrpEMfEKG6O0OHy+Jk X-Received: by 2002:a17:902:e810:b0:194:81c9:b8da with SMTP id u16-20020a170902e81000b0019481c9b8damr2729300plg.3.1675242511683; Wed, 01 Feb 2023 01:08:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675242511; cv=none; d=google.com; s=arc-20160816; b=VdvR2W8LatwjBT8xR25JNA67epOjd3+EJ4rXg/TgnDaskCP+r0dEAnrPdqboAzR4Wo yZMjv7Oj1uoVyvVlWpCt7fNpuwtJNFf5gvYKnlhLYGngs2iZkqS6RmWtM5a2Dc70cWlG C/1OxdG3Idqzk8AuueuxdBFA1TVCJr7KADs5poWp+AV7aR/oXo7GmjZ0lfsDzNrizXWh usiXAyXe0qnnlRLlIIfipO+PqBptFS9xgxhEg1VlgrnhEu7FUPKdCyTzs43P1Ibno4IM VkeDBeuyCvKjDh4qQ/CtK+s+2DTM894okD2JuKBvF41vEasoTKijUvBWPMcO8Ai+njeZ 3S4A== 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=cLalyMjKE9a5scbUfyOFQTtDyJyL4iEKiwpEcPwCF24=; b=ZLhPJJiZlRE7c4H3F+3MhjyvIQLXJPKSyAIA3TLichXyuXAlUWQRMr35mbKawlJdI6 VHkjIhnNsc4S2FR+GfFZQ0r66nhktHXfSUruh5b9iQN+/HOP03QQlQogy3fQNfeugKFA Gwx437Xtmr/4TTXXs1PiG7Ch7N1+C6YB6qofHqswCbUeYpxHKytegyv7F7GG7W8AC6Vq dBDOMDJiL7peDKMb4bvdbTc7e0axt+bVmBi3ik5kQHikyIZz4UL1lOttIlQEa5JGNG9+ 3zzvleleERs0OHgmysp5A7tTcej2/2dWy6tUJmu5D/jwnTVTs8nHEg85IDRe0ieCZd+q AIlQ== 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 j4-20020a170902c3c400b001965f7607cdsi13813974plj.397.2023.02.01.01.08.19; Wed, 01 Feb 2023 01:08:31 -0800 (PST) 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 S231644AbjBAJGX (ORCPT <rfc822;duw91626@gmail.com> + 99 others); Wed, 1 Feb 2023 04:06:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231535AbjBAJGV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 1 Feb 2023 04:06:21 -0500 Received: from exchange.fintech.ru (e10edge.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4438F5DC34; Wed, 1 Feb 2023 01:06:16 -0800 (PST) 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; Wed, 1 Feb 2023 12:06:13 +0300 Received: from KANASHIN1.fintech.ru (10.0.253.125) 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; Wed, 1 Feb 2023 12:06:13 +0300 From: Natalia Petrova <n.petrova@fintech.ru> To: Jesse Brandeburg <jesse.brandeburg@intel.com> CC: Natalia Petrova <n.petrova@fintech.ru>, Tony Nguyen <anthony.l.nguyen@intel.com>, "David S. Miller" <davem@davemloft.net>, "Eric Dumazet" <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, <intel-wired-lan@lists.osuosl.org>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <lvc-project@linuxtesting.org> Subject: [PATCH v3] i40e: Add checking for null for nlmsg_find_attr() Date: Wed, 1 Feb 2023 12:06:10 +0300 Message-ID: <20230201090610.52782-1-n.petrova@fintech.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230125141328.8479-1-n.petrova@fintech.ru> References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.253.125] X-ClientProxiedBy: Ex16-01.fintech.ru (10.0.10.18) 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?1756004688747310918?= X-GMAIL-MSGID: =?utf-8?q?1756619091784554305?= |
Series |
[v3] i40e: Add checking for null for nlmsg_find_attr()
|
|
Commit Message
Natalia Petrova
Feb. 1, 2023, 9:06 a.m. UTC
The result of nlmsg_find_attr() 'br_spec' is dereferenced in nla_for_each_nested(), but it can take NULL value in nla_find() function, which will result in an error. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 51616018dd1b ("i40e: Add support for getlink, setlink ndo ops") Signed-off-by: Natalia Petrova <n.petrova@fintech.ru> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com> --- v3: Fixed mailing list. v2: The remark about the error code by Simon Horman <simon.horman@corigine.com> was taken into account; return value -ENOENT was changed to -EINVAL. drivers/net/ethernet/intel/i40e/i40e_main.c | 2 ++ 1 file changed, 2 insertions(+)
Comments
On 2/1/2023 1:06 AM, Natalia Petrova wrote: > The result of nlmsg_find_attr() 'br_spec' is dereferenced in > nla_for_each_nested(), but it can take NULL value in nla_find() function, > which will result in an error. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: 51616018dd1b ("i40e: Add support for getlink, setlink ndo ops") > Signed-off-by: Natalia Petrova <n.petrova@fintech.ru> > Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com> > --- Thanks for the patch. I've applied it, however, for the future if you could specify the target tree. Simon mentioned it in v2, but his example omitted the tree. i.e. [PATCH v3 net] i40e: Add checking for null for nlmsg_find_attr() Thanks, Tony > v3: Fixed mailing list. > v2: The remark about the error code by Simon Horman <simon.horman@corigine.com> > was taken into account; return value -ENOENT was changed to -EINVAL. > drivers/net/ethernet/intel/i40e/i40e_main.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c > index 53d0083e35da..4626d2a1af91 100644 > --- a/drivers/net/ethernet/intel/i40e/i40e_main.c > +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c > @@ -13167,6 +13167,8 @@ static int i40e_ndo_bridge_setlink(struct net_device *dev, > } > > br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC); > + if (!br_spec) > + return -EINVAL; > > nla_for_each_nested(attr, br_spec, rem) { > __u16 mode;
> -----Original Message----- > From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of > Natalia Petrova > Sent: Wednesday, February 1, 2023 2:36 PM > To: Brandeburg, Jesse <jesse.brandeburg@intel.com> > Cc: lvc-project@linuxtesting.org; intel-wired-lan@lists.osuosl.org; Natalia > Petrova <n.petrova@fintech.ru>; linux-kernel@vger.kernel.org; Eric > Dumazet <edumazet@google.com>; Nguyen, Anthony L > <anthony.l.nguyen@intel.com>; netdev@vger.kernel.org; Jakub Kicinski > <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; David S. Miller > <davem@davemloft.net> > Subject: [Intel-wired-lan] [PATCH v3] i40e: Add checking for null for > nlmsg_find_attr() > > The result of nlmsg_find_attr() 'br_spec' is dereferenced in > nla_for_each_nested(), but it can take NULL value in nla_find() function, > which will result in an error. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: 51616018dd1b ("i40e: Add support for getlink, setlink ndo ops") > Signed-off-by: Natalia Petrova <n.petrova@fintech.ru> > Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com> > --- > v3: Fixed mailing list. > v2: The remark about the error code by Simon Horman > <simon.horman@corigine.com> was taken into account; return value - > ENOENT was changed to -EINVAL. > drivers/net/ethernet/intel/i40e/i40e_main.c | 2 ++ > 1 file changed, 2 insertions(+) > Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 53d0083e35da..4626d2a1af91 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -13167,6 +13167,8 @@ static int i40e_ndo_bridge_setlink(struct net_device *dev, } br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC); + if (!br_spec) + return -EINVAL; nla_for_each_nested(attr, br_spec, rem) { __u16 mode;