From: Horatiu Vultur <horatiu.vultur@microchip.com>
To: Shang XiaoJing <shangxiaojing@huawei.com>
Cc: <UNGLinuxDriver@microchip.com>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<lars.povlsen@microchip.com>, <Steen.Hegelund@microchip.com>,
<daniel.machon@microchip.com>, <rmk+kernel@armlinux.org.uk>,
<casper.casan@gmail.com>, <bjarni.jonasson@microchip.com>,
<netdev@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 1/2] net: lan966x: Fix potential null-ptr-deref in lan966x_stats_init()
Date: Mon, 14 Nov 2022 15:20:17 +0100 [thread overview]
Message-ID: <20221114142017.bqaeabujh4rlxl5c@soft-dev3-1> (raw)
In-Reply-To: <20221114133853.5384-2-shangxiaojing@huawei.com>
The 11/14/2022 21:38, Shang XiaoJing wrote:
> [Some people who received this message don't often get email from shangxiaojing@huawei.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> lan966x_stats_init() calls create_singlethread_workqueue() and not
> checked the ret value, which may return NULL. And a null-ptr-deref may
> happen:
>
> lan966x_stats_init()
> create_singlethread_workqueue() # failed, lan966x->stats_queue is NULL
> queue_delayed_work()
> queue_delayed_work_on()
> __queue_delayed_work() # warning here, but continue
> __queue_work() # access wq->flags, null-ptr-deref
>
> Check the ret value and return -ENOMEM if it is NULL.
It looks good to me.
Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
>
> Fixes: 12c2d0a5b8e2 ("net: lan966x: add ethtool configuration and statistics")
> Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
> ---
> drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c b/drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c
> index e58a27fd8b50..0fb0efc224be 100644
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c
> @@ -708,6 +708,9 @@ int lan966x_stats_init(struct lan966x *lan966x)
> snprintf(queue_name, sizeof(queue_name), "%s-stats",
> dev_name(lan966x->dev));
> lan966x->stats_queue = create_singlethread_workqueue(queue_name);
> + if (!lan966x->stats_queue)
> + return -ENOMEM;
> +
> INIT_DELAYED_WORK(&lan966x->stats_work, lan966x_check_stats_work);
> queue_delayed_work(lan966x->stats_queue, &lan966x->stats_work,
> LAN966X_STATS_CHECK_DELAY);
> --
> 2.17.1
>
--
/Horatiu
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-11-14 14:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-14 13:38 [PATCH 0/2] net: microchip: Fix potential null-ptr-deref due to create_singlethread_workqueue() Shang XiaoJing
2022-11-14 13:38 ` [PATCH 1/2] net: lan966x: Fix potential null-ptr-deref in lan966x_stats_init() Shang XiaoJing
2022-11-14 14:20 ` Horatiu Vultur [this message]
2022-11-14 13:38 ` [PATCH 2/2] net: microchip: sparx5: Fix potential null-ptr-deref in sparx_stats_init() and sparx5_start() Shang XiaoJing
2022-11-16 9:20 ` [PATCH 0/2] net: microchip: Fix potential null-ptr-deref due to create_singlethread_workqueue() 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=20221114142017.bqaeabujh4rlxl5c@soft-dev3-1 \
--to=horatiu.vultur@microchip.com \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=bjarni.jonasson@microchip.com \
--cc=casper.casan@gmail.com \
--cc=daniel.machon@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=lars.povlsen@microchip.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rmk+kernel@armlinux.org.uk \
--cc=shangxiaojing@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox