From: netdev-bot+sashiko@kernel.org
To: shaojijie@huawei.com
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, andrew+netdev@lunn.ch, shenjian15@huawei.com,
liuyonglong@huawei.com, chenhao418@huawei.com,
yangshuaisong@h-partners.com, ningwei15@huawei.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 net 4/4] net: hns3: fix use-after-free in debugfs read during reset/unload
Date: Sun, 22 Nov 2026 13:24:02 +0000 [thread overview]
Message-ID: <179535384216.3135.13172932788054177257@kernel.org> (raw)
In-Reply-To: <20261118130330.3026625-5-shaojijie@huawei.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The comment on the new `struct hnae3_handle::dbg_mutex` field in
drivers/net/ethernet/hisilicon/hns3/hnae3.h reads "protect debugfs…
--
net: hns3: fix use-after-free in debugfs read during reset/unload
This patch adds a dbg_mutex to struct hnae3_handle. The enet-layer debugfs
show callbacks take it, and so do the reset, driver unload and ethtool ring
resize paths, which keeps the readers away from priv->ring, priv->tqp_vector
and ring->desc while those are being freed. The readers also check the
device state on every iteration and return -EBUSY when the device is busy.
Closes: https://lore.kernel.org/all/a0853cd9-cab5-441d-b181-8ba97f2f58b0@huawei.com/
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
> index 4286af9239b01..e94cc33da8643 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
> +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
> @@ -944,6 +944,7 @@ struct hnae3_handle {
>
> u8 netdev_flags;
> struct dentry *hnae3_dbgfs;
> + struct mutex dbg_mutex; /* protect debugfs against reset/unload */
[Severity: Low]
This isn't a bug, but is this comment a little narrower and a little
broader than what the lock actually does?
On the writer side, hns3_set_ringparam() also takes h->dbg_mutex around
hns3_init_all_ring(), the memcpy() restore and hns3_fini_ring() on the
backup rings:
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
> @@ -1252,6 +1252,7 @@ static int hns3_set_ringparam(struct net_device *ndev,
> if (if_running)
> ndev->netdev_ops->ndo_stop(ndev);
>
> + mutex_lock(&h->dbg_mutex);
> hns3_change_all_ring_bd_num(priv, new_ringparam.tx_desc_num,
> new_ringparam.rx_desc_num);
Ring resize is neither a reset nor an unload, so the field comment does
not mention it.
On the reader side, only the enet-layer seq_file callbacks take the
mutex (coal_info, rx/tx_queue_info, queue_map, page_pool_info, bd_info).
The hclge-layer readers that hns3_dbg_common_init_t2() registers through
ops->dbg_get_read_func() live under the same handle->hnae3_dbgfs tree,
and they never take it.
The commit message says the mutex is "used by enet-layer debugfs
callbacks", but this comment is the only place in the tree that
describes the lock's scope.
Could the comment say that the lock serializes the enet-layer debugfs
readers against the paths that free or rebuild priv->ring,
priv->tqp_vector and ring->desc (reset, unload and ring resize)? Then a
future writer would know it has to take the lock, and an hclge-layer
reader would not assume it is protected.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118130330.3026625-1-shaojijie%40huawei.com
prev parent reply other threads:[~2026-11-22 13:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 13:03 [PATCH net v5 0/4] net: hns3: fix multiple bugs in reset/error paths Jijie Shao
2026-11-18 13:03 ` [PATCH v5 net 1/4] net: hns3: fix vector resource leak in hns3_nic_alloc_vector_data Jijie Shao
2026-11-18 13:03 ` [PATCH v5 net 2/4] net: hns3: fix page_pool leak in hns3_alloc_ring_memory error path Jijie Shao
2026-11-18 13:03 ` [PATCH v5 net 3/4] net: hns3: fix interface stuck after OOM with full hardware rx queue Jijie Shao
2026-11-22 13:24 ` netdev-bot+sashiko
2026-11-18 13:03 ` [PATCH v5 net 4/4] net: hns3: fix use-after-free in debugfs read during reset/unload Jijie Shao
2026-11-22 13:24 ` netdev-bot+sashiko [this message]
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=179535384216.3135.13172932788054177257@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=chenhao418@huawei.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuyonglong@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=ningwei15@huawei.com \
--cc=pabeni@redhat.com \
--cc=shaojijie@huawei.com \
--cc=shenjian15@huawei.com \
--cc=yangshuaisong@h-partners.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