2023-03-07 07:32:00

by Dongliang Mu

[permalink] [raw]
Subject: [PATCH] net: ieee802154: fix a null pointer in nl802154_trigger_scan

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: [email protected]
Signed-off-by: Dongliang Mu <[email protected]>
---
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;
}
--
2.34.1



2023-03-07 08:43:54

by Denis Kirjanov

[permalink] [raw]
Subject: 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: [email protected]
> Signed-off-by: Dongliang Mu <[email protected]>

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;
> }

2023-03-07 09:09:15

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH] net: ieee802154: fix a null pointer in nl802154_trigger_scan

Hello,

[email protected] 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/[email protected]/T/#u

> > Reported-and-tested-by: [email protected]

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 <[email protected]>
>
> 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

2023-03-07 09:10:37

by Dongliang Mu

[permalink] [raw]
Subject: Re: Re: [PATCH] net: ieee802154: fix a null pointer in nl802154_trigger_scan




> -----原始邮件-----
> 发件人: "Denis Kirjanov" <[email protected]>
> 发送时间: 2023-03-07 16:43:46 (星期二)
> 收件人: "Dongliang Mu" <[email protected]>, "Alexander Aring" <[email protected]>, "Stefan Schmidt" <[email protected]>, "Miquel Raynal" <[email protected]>, "David S. Miller" <[email protected]>, "Eric Dumazet" <[email protected]>, "Jakub Kicinski" <[email protected]>, "Paolo Abeni" <[email protected]>
> 抄送: [email protected], [email protected], [email protected], [email protected]
> 主题: 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: [email protected]
> > Signed-off-by: Dongliang Mu <[email protected]>
>
> 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;
> > }

2023-03-07 09:22:44

by Dongliang Mu

[permalink] [raw]
Subject: Re: Re: [PATCH] net: ieee802154: fix a null pointer in nl802154_trigger_scan




> -----原始邮件-----
> 发件人: "Miquel Raynal" <[email protected]>
> 发送时间: 2023-03-07 17:09:03 (星期二)
> 收件人: "Denis Kirjanov" <[email protected]>
> 抄送: "Dongliang Mu" <[email protected]>, "Alexander Aring" <[email protected]>, "Stefan Schmidt" <[email protected]>, "David
> S. Miller" <[email protected]>, "Eric Dumazet" <[email protected]>, "Jakub
> Kicinski" <[email protected]>, "Paolo Abeni" <[email protected]>, [email protected], [email protected], [email protected], [email protected]
> 主题: Re: [PATCH] net: ieee802154: fix a null pointer in nl802154_trigger_scan
>
> Hello,
>
> [email protected] 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/[email protected]/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: [email protected]
>
> 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 <[email protected]>
> >
> > 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

2023-03-07 09:34:17

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH] net: ieee802154: fix a null pointer in nl802154_trigger_scan

Hi 慕冬亮,

[email protected] wrote on Tue, 7 Mar 2023 17:21:49 +0800 (GMT+08:00):

> > -----原始邮件-----
> > 发件人: "Miquel Raynal" <[email protected]>
> > 发送时间: 2023-03-07 17:09:03 (星期二)
> > 收件人: "Denis Kirjanov" <[email protected]>
> > 抄送: "Dongliang Mu" <[email protected]>, "Alexander Aring" <[email protected]>, "Stefan Schmidt" <[email protected]>, "David
> > S. Miller" <[email protected]>, "Eric Dumazet" <[email protected]>, "Jakub
> > Kicinski" <[email protected]>, "Paolo Abeni" <[email protected]>, [email protected], [email protected], [email protected], [email protected]
> > 主题: Re: [PATCH] net: ieee802154: fix a null pointer in nl802154_trigger_scan
> >
> > Hello,
> >
> > [email protected] 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/[email protected]/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: [email protected]
> >
> > 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 <[email protected]>
> > >
> > > 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