From: Eric Dumazet <eric.dumazet@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>, davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net-next] ethtool: always write dev in ethnl_parse_header_dev_get
Date: Wed, 15 Dec 2021 02:47:48 -0800 [thread overview]
Message-ID: <3ea44009-3032-002c-f514-9067ffb00597@gmail.com> (raw)
In-Reply-To: <20211214154725.451682-1-kuba@kernel.org>
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;
> }
next prev parent reply other threads:[~2021-12-15 10:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2021-12-15 15:10 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3ea44009-3032-002c-f514-9067ffb00597@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).