* [PATCH net-next] ethtool: always write dev in ethnl_parse_header_dev_get
@ 2021-12-14 15:47 Jakub Kicinski
2021-12-15 10:47 ` Eric Dumazet
2021-12-15 15:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Kicinski @ 2021-12-14 15:47 UTC (permalink / raw)
To: davem; +Cc: netdev, Jakub Kicinski
Commit 0976b888a150 ("ethtool: fix null-ptr-deref on ref tracker")
made the write to req_info.dev conditional, but as Eric points out
in a different follow up the structure is often allocated on the
stack and not kzalloc()'d so seems safer to always write the dev,
in case it's garbage on input.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
net/ethtool/netlink.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 767fb3f17267..f09c62302a9a 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -141,10 +141,9 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info,
return -EINVAL;
}
- if (dev) {
- req_info->dev = dev;
+ req_info->dev = dev;
+ if (dev)
netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
- }
req_info->flags = flags;
return 0;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ethtool: always write dev in ethnl_parse_header_dev_get
2021-12-14 15:47 [PATCH net-next] ethtool: always write dev in ethnl_parse_header_dev_get Jakub Kicinski
@ 2021-12-15 10:47 ` Eric Dumazet
2021-12-15 15:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2021-12-15 10:47 UTC (permalink / raw)
To: Jakub Kicinski, davem; +Cc: netdev
On 12/14/21 7:47 AM, Jakub Kicinski wrote:
> Commit 0976b888a150 ("ethtool: fix null-ptr-deref on ref tracker")
> made the write to req_info.dev conditional, but as Eric points out
> in a different follow up the structure is often allocated on the
> stack and not kzalloc()'d so seems safer to always write the dev,
> in case it's garbage on input.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Yep, this was basically how I wanted to fix this.
Reviewed-by: Eric Dumazet <edumazet@google.com>
> ---
> net/ethtool/netlink.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
> index 767fb3f17267..f09c62302a9a 100644
> --- a/net/ethtool/netlink.c
> +++ b/net/ethtool/netlink.c
> @@ -141,10 +141,9 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info,
> return -EINVAL;
> }
>
> - if (dev) {
> - req_info->dev = dev;
> + req_info->dev = dev;
> + if (dev)
> netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
> - }
> req_info->flags = flags;
> return 0;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ethtool: always write dev in ethnl_parse_header_dev_get
2021-12-14 15:47 [PATCH net-next] ethtool: always write dev in ethnl_parse_header_dev_get Jakub Kicinski
2021-12-15 10:47 ` Eric Dumazet
@ 2021-12-15 15:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-15 15:10 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: davem, netdev
Hello:
This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Tue, 14 Dec 2021 07:47:25 -0800 you wrote:
> Commit 0976b888a150 ("ethtool: fix null-ptr-deref on ref tracker")
> made the write to req_info.dev conditional, but as Eric points out
> in a different follow up the structure is often allocated on the
> stack and not kzalloc()'d so seems safer to always write the dev,
> in case it's garbage on input.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>
> [...]
Here is the summary with links:
- [net-next] ethtool: always write dev in ethnl_parse_header_dev_get
https://git.kernel.org/netdev/net-next/c/3bc14ea0d12a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-15 15:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 15:47 [PATCH net-next] ethtool: always write dev in ethnl_parse_header_dev_get Jakub Kicinski
2021-12-15 10:47 ` Eric Dumazet
2021-12-15 15:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).