Message ID | 20230307073004.74224-1-dzm91@hust.edu.cn |
---|---|
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 v21csp2298683wrd; Mon, 6 Mar 2023 23:49:36 -0800 (PST) X-Google-Smtp-Source: AK7set/qKtm3W27mCCv1Dkx/VcS5v/ZiI0Y30OXSS4J5lxlqZO/6AHxUZoytHznhZLU30CWEGWzw X-Received: by 2002:a17:902:da90:b0:19c:e405:4446 with SMTP id j16-20020a170902da9000b0019ce4054446mr16103387plx.30.1678175376316; Mon, 06 Mar 2023 23:49:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678175376; cv=none; d=google.com; s=arc-20160816; b=LftKXClqwx9nPyChZiXdBFhOhs3seN/CCvWdxmlZzhkWVNZc4uGHgm082JoFCtVGZx wMqVo34+plKY2ysAAmzm97Wmw9e3WWzNUsoB4qJ6mc1HH8TTRhuOalFHd2Q/mhDrB7qU gRSWDP4AIfRkxBUgKO7OXJPAQEMrXxDTHTPxbqo0zQT9KqBI9/3hSnISCMXb1ofxxPUC voIWX2xFETw4+gexLd0Mk1REVT2TEKRGyiRgqbQ+TWmFa8sQ/+8sVRvQuDTnKmgO/Bue d85xwOZrhWuW/VIAsvKgZPWcFdumFKS1Z8GUzE9dnp0nlHxbRAT9zLCOYQq2CgLH8DoQ JKoA== 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 :message-id:date:subject:cc:to:from; bh=axcHpB1O5LRntnOEx733oBkfW5mEW0ifZ2goNC5+VDg=; b=BYr8McSx9szXAGl57H1PGNF30nVAhfQwSDkDrYP+0Phr3T8ZxOyIrqhanYPGL9ZP18 v3737zqo3FO2J7NcA8qb+H15GfLwUF57eKl6YZIyOnyIzKgydV0JXMHySnsjIv4Jx9D/ MHY4X/EJ+D0LhPTzIED/HYzbUroLFGiAILzFC6EW2QIrLUfRDolV56Hu3qI31qEsulU3 xR3qzxEpiZj7NyDkSnb1U5ULdCxPAMhWyaJdXeIOLYfEg8sAzNk8flBVNJo/TpxfV3w2 ISYkXrgMvrjTmk8sA6KgBTcEyacZ+aFvNxOn88Hg2PlFpzAFhG4ubFHQ+HA/SN/ToL+5 LeiA== 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 c7-20020a654207000000b004f288fe9a47si11218318pgq.520.2023.03.06.23.49.24; Mon, 06 Mar 2023 23:49:36 -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 S230293AbjCGHb6 (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Tue, 7 Mar 2023 02:31:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbjCGHbz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 7 Mar 2023 02:31:55 -0500 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 419944DE2D for <linux-kernel@vger.kernel.org>; Mon, 6 Mar 2023 23:31:53 -0800 (PST) Received: from pride-PowerEdge-R740.. ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 3277U5pJ009289-3277U5pM009289 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 7 Mar 2023 15:30:10 +0800 From: Dongliang Mu <dzm91@hust.edu.cn> To: Alexander Aring <alex.aring@gmail.com>, Stefan Schmidt <stefan@datenfreihafen.org>, Miquel Raynal <miquel.raynal@bootlin.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: Dongliang Mu <dzm91@hust.edu.cn>, syzbot+bd85b31816913a32e473@syzkaller.appspotmail.com, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: ieee802154: fix a null pointer in nl802154_trigger_scan Date: Tue, 7 Mar 2023 15:30:03 +0800 Message-Id: <20230307073004.74224-1-dzm91@hust.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: dzm91@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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?1759694423429150212?= X-GMAIL-MSGID: =?utf-8?q?1759694423429150212?= |
Series |
net: ieee802154: fix a null pointer in nl802154_trigger_scan
|
|
Commit Message
Dongliang Mu
March 7, 2023, 7:30 a.m. UTC
There is a null pointer dereference if NL802154_ATTR_SCAN_TYPE is
not set by the user.
Fix this by adding a null pointer check.
Reported-and-tested-by: syzbot+bd85b31816913a32e473@syzkaller.appspotmail.com
Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
---
net/ieee802154/nl802154.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On 3/7/23 10:30, Dongliang Mu wrote: > There is a null pointer dereference if NL802154_ATTR_SCAN_TYPE is > not set by the user. > > Fix this by adding a null pointer check. > > Reported-and-tested-by: syzbot+bd85b31816913a32e473@syzkaller.appspotmail.com > Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn> Please add a Fixes: tag > --- > net/ieee802154/nl802154.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c > index 2215f576ee37..1cf00cffd63f 100644 > --- a/net/ieee802154/nl802154.c > +++ b/net/ieee802154/nl802154.c > @@ -1412,7 +1412,8 @@ static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info) > return -EOPNOTSUPP; > } > > - if (!nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) { > + if (!info->attrs[NL802154_ATTR_SCAN_TYPE] || > + !nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) { > NL_SET_ERR_MSG(info->extack, "Malformed request, missing scan type"); > return -EINVAL; > }
Hello, dkirjanov@suse.de wrote on Tue, 7 Mar 2023 11:43:46 +0300: > On 3/7/23 10:30, Dongliang Mu wrote: > > There is a null pointer dereference if NL802154_ATTR_SCAN_TYPE is > > not set by the user. > > > > Fix this by adding a null pointer check. Thanks for the patch! This has been fixed already: https://lore.kernel.org/linux-wpan/20230301154450.547716-1-miquel.raynal@bootlin.com/T/#u > > Reported-and-tested-by: syzbot+bd85b31816913a32e473@syzkaller.appspotmail.com Just for reference, this tag shall not be used: "Please do not use combined tags, e.g. ``Reported-and-tested-by``" Documentation/process/maintainer-tip.rst > > Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn> > > Please add a Fixes: tag > > > --- > > net/ieee802154/nl802154.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c > > index 2215f576ee37..1cf00cffd63f 100644 > > --- a/net/ieee802154/nl802154.c > > +++ b/net/ieee802154/nl802154.c > > @@ -1412,7 +1412,8 @@ static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info) > > return -EOPNOTSUPP; > > } > > > > - if (!nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) { > > + if (!info->attrs[NL802154_ATTR_SCAN_TYPE] || > > + !nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) { > > NL_SET_ERR_MSG(info->extack, "Malformed request, missing scan type"); > > return -EINVAL; > > } Thanks, Miquèl
> -----原始邮件----- > 发件人: "Denis Kirjanov" <dkirjanov@suse.de> > 发送时间: 2023-03-07 16:43:46 (星期二) > 收件人: "Dongliang Mu" <dzm91@hust.edu.cn>, "Alexander Aring" <alex.aring@gmail.com>, "Stefan Schmidt" <stefan@datenfreihafen.org>, "Miquel Raynal" <miquel.raynal@bootlin.com>, "David S. Miller" <davem@davemloft.net>, "Eric Dumazet" <edumazet@google.com>, "Jakub Kicinski" <kuba@kernel.org>, "Paolo Abeni" <pabeni@redhat.com> > 抄送: syzbot+bd85b31816913a32e473@syzkaller.appspotmail.com, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org > 主题: Re: [PATCH] net: ieee802154: fix a null pointer in nl802154_trigger_scan > > > > On 3/7/23 10:30, Dongliang Mu wrote: > > There is a null pointer dereference if NL802154_ATTR_SCAN_TYPE is > > not set by the user. > > > > Fix this by adding a null pointer check. > > > > Reported-and-tested-by: syzbot+bd85b31816913a32e473@syzkaller.appspotmail.com > > Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn> > > Please add a Fixes: tag I've sent a v2 patch. Thanks for your reminder. > > > --- > > net/ieee802154/nl802154.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c > > index 2215f576ee37..1cf00cffd63f 100644 > > --- a/net/ieee802154/nl802154.c > > +++ b/net/ieee802154/nl802154.c > > @@ -1412,7 +1412,8 @@ static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info) > > return -EOPNOTSUPP; > > } > > > > - if (!nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) { > > + if (!info->attrs[NL802154_ATTR_SCAN_TYPE] || > > + !nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) { > > NL_SET_ERR_MSG(info->extack, "Malformed request, missing scan type"); > > return -EINVAL; > > }
> -----原始邮件----- > 发件人: "Miquel Raynal" <miquel.raynal@bootlin.com> > 发送时间: 2023-03-07 17:09:03 (星期二) > 收件人: "Denis Kirjanov" <dkirjanov@suse.de> > 抄送: "Dongliang Mu" <dzm91@hust.edu.cn>, "Alexander Aring" <alex.aring@gmail.com>, "Stefan Schmidt" <stefan@datenfreihafen.org>, "David > S. Miller" <davem@davemloft.net>, "Eric Dumazet" <edumazet@google.com>, "Jakub > Kicinski" <kuba@kernel.org>, "Paolo Abeni" <pabeni@redhat.com>, syzbot+bd85b31816913a32e473@syzkaller.appspotmail.com, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org > 主题: Re: [PATCH] net: ieee802154: fix a null pointer in nl802154_trigger_scan > > Hello, > > dkirjanov@suse.de wrote on Tue, 7 Mar 2023 11:43:46 +0300: > > > On 3/7/23 10:30, Dongliang Mu wrote: > > > There is a null pointer dereference if NL802154_ATTR_SCAN_TYPE is > > > not set by the user. > > > > > > Fix this by adding a null pointer check. > > Thanks for the patch! This has been fixed already: > https://lore.kernel.org/linux-wpan/20230301154450.547716-1-miquel.raynal@bootlin.com/T/#u Oh, I see. Thanks for your reply. A small issue: should we still check !nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])? > > > > Reported-and-tested-by: syzbot+bd85b31816913a32e473@syzkaller.appspotmail.com > > Just for reference, this tag shall not be used: > > "Please do not use combined tags, e.g. > ``Reported-and-tested-by``" > Documentation/process/maintainer-tip.rst > Okay. This is suggested by Syzbot. I will use separate tags in the future. > > > Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn> > > > > Please add a Fixes: tag > > > > > --- > > > net/ieee802154/nl802154.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c > > > index 2215f576ee37..1cf00cffd63f 100644 > > > --- a/net/ieee802154/nl802154.c > > > +++ b/net/ieee802154/nl802154.c > > > @@ -1412,7 +1412,8 @@ static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info) > > > return -EOPNOTSUPP; > > > } > > > > > > - if (!nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) { > > > + if (!info->attrs[NL802154_ATTR_SCAN_TYPE] || > > > + !nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) { > > > NL_SET_ERR_MSG(info->extack, "Malformed request, missing scan type"); > > > return -EINVAL; > > > } > > > Thanks, > Miquèl -- Best regards, Dongliang Mu
Hi 慕冬亮, dzm91@hust.edu.cn wrote on Tue, 7 Mar 2023 17:21:49 +0800 (GMT+08:00): > > -----原始邮件----- > > 发件人: "Miquel Raynal" <miquel.raynal@bootlin.com> > > 发送时间: 2023-03-07 17:09:03 (星期二) > > 收件人: "Denis Kirjanov" <dkirjanov@suse.de> > > 抄送: "Dongliang Mu" <dzm91@hust.edu.cn>, "Alexander Aring" <alex.aring@gmail.com>, "Stefan Schmidt" <stefan@datenfreihafen.org>, "David > > S. Miller" <davem@davemloft.net>, "Eric Dumazet" <edumazet@google.com>, "Jakub > > Kicinski" <kuba@kernel.org>, "Paolo Abeni" <pabeni@redhat.com>, syzbot+bd85b31816913a32e473@syzkaller.appspotmail.com, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org > > 主题: Re: [PATCH] net: ieee802154: fix a null pointer in nl802154_trigger_scan > > > > Hello, > > > > dkirjanov@suse.de wrote on Tue, 7 Mar 2023 11:43:46 +0300: > > > > > On 3/7/23 10:30, Dongliang Mu wrote: > > > > There is a null pointer dereference if NL802154_ATTR_SCAN_TYPE is > > > > not set by the user. > > > > > > > > Fix this by adding a null pointer check. > > > > Thanks for the patch! This has been fixed already: > > https://lore.kernel.org/linux-wpan/20230301154450.547716-1-miquel.raynal@bootlin.com/T/#u > > Oh, I see. Thanks for your reply. > > A small issue: should we still check !nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])? Isn't it already handled? There is a switch case over it with a default statement to handle unsupported scan types. > > > > Reported-and-tested-by: syzbot+bd85b31816913a32e473@syzkaller.appspotmail.com > > > > Just for reference, this tag shall not be used: > > > > "Please do not use combined tags, e.g. > > ``Reported-and-tested-by``" > > Documentation/process/maintainer-tip.rst > > > > Okay. This is suggested by Syzbot. I will use separate tags in the future. > > > > > Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn> > > > > > > Please add a Fixes: tag > > > > > > > --- > > > > net/ieee802154/nl802154.c | 3 ++- > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c > > > > index 2215f576ee37..1cf00cffd63f 100644 > > > > --- a/net/ieee802154/nl802154.c > > > > +++ b/net/ieee802154/nl802154.c > > > > @@ -1412,7 +1412,8 @@ static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info) > > > > return -EOPNOTSUPP; > > > > } > > > > > > > > - if (!nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) { > > > > + if (!info->attrs[NL802154_ATTR_SCAN_TYPE] || > > > > + !nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) { > > > > NL_SET_ERR_MSG(info->extack, "Malformed request, missing scan type"); > > > > return -EINVAL; > > > > } > > > > > > Thanks, > > Miquèl > > > -- > Best regards, > Dongliang Mu Thanks, Miquèl
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c index 2215f576ee37..1cf00cffd63f 100644 --- a/net/ieee802154/nl802154.c +++ b/net/ieee802154/nl802154.c @@ -1412,7 +1412,8 @@ static int nl802154_trigger_scan(struct sk_buff *skb, struct genl_info *info) return -EOPNOTSUPP; } - if (!nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) { + if (!info->attrs[NL802154_ATTR_SCAN_TYPE] || + !nla_get_u8(info->attrs[NL802154_ATTR_SCAN_TYPE])) { NL_SET_ERR_MSG(info->extack, "Malformed request, missing scan type"); return -EINVAL; }