2023-01-17 00:36:55

by Piergiorgio Beruto

[permalink] [raw]
Subject: [PATCH net-next 1/1] ethtool/plca: fix potential NULL pointer access

Fix problem found by syzbot dereferencing a device pointer.

Signed-off-by: Piergiorgio Beruto <[email protected]>
Reported-by: [email protected]
Fixes: 8580e16c28f3 ("net/ethtool: add netlink interface for the PLCA RS")
---
net/ethtool/plca.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/net/ethtool/plca.c b/net/ethtool/plca.c
index be7404dc9ef2..bc3d31f99998 100644
--- a/net/ethtool/plca.c
+++ b/net/ethtool/plca.c
@@ -155,6 +155,8 @@ int ethnl_set_plca_cfg(struct sk_buff *skb, struct genl_info *info)
return ret;

dev = req_info.dev;
+ if(!dev)
+ return -ENODEV;

rtnl_lock();

--
2.37.4


2023-01-17 00:44:04

by Vladimir Oltean

[permalink] [raw]
Subject: Re: [PATCH net-next 1/1] ethtool/plca: fix potential NULL pointer access

On Tue, Jan 17, 2023 at 12:57:19AM +0100, Piergiorgio Beruto wrote:
> Fix problem found by syzbot dereferencing a device pointer.
>
> Signed-off-by: Piergiorgio Beruto <[email protected]>
> Reported-by: [email protected]
> Fixes: 8580e16c28f3 ("net/ethtool: add netlink interface for the PLCA RS")
> ---
> net/ethtool/plca.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/ethtool/plca.c b/net/ethtool/plca.c
> index be7404dc9ef2..bc3d31f99998 100644
> --- a/net/ethtool/plca.c
> +++ b/net/ethtool/plca.c
> @@ -155,6 +155,8 @@ int ethnl_set_plca_cfg(struct sk_buff *skb, struct genl_info *info)
> return ret;
>
> dev = req_info.dev;
> + if(!dev)
> + return -ENODEV;

Shouldn't be necessary. The fact that you pass "true" to the
"require_dev" argument of ethnl_parse_header_dev_get() takes care
specifically of that.

Looking at that syzbot report, it looks like you solved it with commit
28dbf774bc87 ("plca.c: fix obvious mistake in checking retval"). Or was
that not the only issue?

>
> rtnl_lock();
>
> --
> 2.37.4
>

2023-01-17 09:24:03

by Piergiorgio Beruto

[permalink] [raw]
Subject: Re: [PATCH net-next 1/1] ethtool/plca: fix potential NULL pointer access

On Tue, Jan 17, 2023 at 02:34:26AM +0200, Vladimir Oltean wrote:
> On Tue, Jan 17, 2023 at 12:57:19AM +0100, Piergiorgio Beruto wrote:
> > Fix problem found by syzbot dereferencing a device pointer.
> >
> > Signed-off-by: Piergiorgio Beruto <[email protected]>
> > Reported-by: [email protected]
> > Fixes: 8580e16c28f3 ("net/ethtool: add netlink interface for the PLCA RS")
> > ---
> > net/ethtool/plca.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/net/ethtool/plca.c b/net/ethtool/plca.c
> > index be7404dc9ef2..bc3d31f99998 100644
> > --- a/net/ethtool/plca.c
> > +++ b/net/ethtool/plca.c
> > @@ -155,6 +155,8 @@ int ethnl_set_plca_cfg(struct sk_buff *skb, struct genl_info *info)
> > return ret;
> >
> > dev = req_info.dev;
> > + if(!dev)
> > + return -ENODEV;
>
> Shouldn't be necessary. The fact that you pass "true" to the
> "require_dev" argument of ethnl_parse_header_dev_get() takes care
> specifically of that.
>
> Looking at that syzbot report, it looks like you solved it with commit
> 28dbf774bc87 ("plca.c: fix obvious mistake in checking retval"). Or was
> that not the only issue?
Oh, I believe you are correct.
I probably confused which version the bug was reported against.

Please, ignore this patch...
Thanks!

Piergiorgio

>
> >
> > rtnl_lock();
> >
> > --
> > 2.37.4
> >