From: Leon Romanovsky <leon@kernel.org>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Michal Kubecek <mkubecek@suse.cz>
Subject: Re: [PATCH net-next] net: ethtool: fix NULL pointer dereference in stats_prepare_data()
Date: Tue, 24 Jan 2023 14:28:18 +0200 [thread overview]
Message-ID: <Y8/O4tf53ZemTABX@unreal> (raw)
In-Reply-To: <20230124110801.3628545-1-vladimir.oltean@nxp.com>
On Tue, Jan 24, 2023 at 01:08:01PM +0200, Vladimir Oltean wrote:
> In the following call path:
>
> ethnl_default_dumpit
> -> ethnl_default_dump_one
> -> ctx->ops->prepare_data
> -> stats_prepare_data
>
> struct genl_info *info will be passed as NULL, and stats_prepare_data()
> dereferences it while getting the extended ack pointer.
>
> To avoid that, just set the extack to NULL if "info" is NULL, since the
> netlink extack handling messages know how to deal with that.
>
> The pattern "info ? info->extack : NULL" is present in quite a few other
> "prepare_data" implementations, so it's clear that it's a more general
> problem to be dealt with at a higher level, but the code should have at
> least adhered to the current conventions to avoid the NULL dereference.
>
> Fixes: 04692c9020b7 ("net: ethtool: netlink: retrieve stats from multiple sources (eMAC, pMAC)")
> Reported-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
> net/ethtool/stats.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
next prev parent reply other threads:[~2023-01-24 12:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-24 11:08 [PATCH net-next] net: ethtool: fix NULL pointer dereference in stats_prepare_data() Vladimir Oltean
2023-01-24 12:28 ` Leon Romanovsky [this message]
2023-01-25 0:23 ` Jakub Kicinski
2023-01-25 0:45 ` Vladimir Oltean
2023-01-25 0:52 ` Jakub Kicinski
2023-01-25 0:53 ` Vladimir Oltean
2023-01-25 1:17 ` Jakub Kicinski
2023-01-25 10:00 ` 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=Y8/O4tf53ZemTABX@unreal \
--to=leon@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.