From: sashiko-bot@kernel.org
To: "Wei Hu" <weh@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org, linux-rdma@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH net-next v6 03/13] net: mana: keep per-queue statistics in the port context
Date: Sat, 10 Oct 2026 14:42:05 +0000 [thread overview]
Message-ID: <sashiko-outbox-166660@kernel.org> (raw)
In-Reply-To: <35bb5bd322e53edfb2e53e4b57ed2e678f3b5105.1790795005.git.weh@linux.microsoft.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] net: mana: UAF in ndo_get_stats64 due to premature free in mana_remove
- [Medium] net: mana: lost xdp_xmit stats due to lockless update in mana_xdp_xmit()
--
commit d18c42b1a688757d3c44ba3c118c5293e960c9e8
Author: Long Li <longli@microsoft.com>
net: mana: keep per-queue statistics in the port context
This patch prepares port-lifetime RX/TX statistics before introducing
live queue replacement. It allocates max_queues slots before netdev
registration and preserves counters while the interface is down.
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_bpf.c b/drivers/net/ethernet/microsoft/mana/mana_bpf.c
> index ff54f89668251..1905214bec487 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_bpf.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_bpf.c
> @@ -68,7 +68,7 @@ int mana_xdp_xmit(struct net_device *ndev, int n, struct xdp_frame **frames,
> count++;
> }
>
> - tx_stats = &apc->tx_qp[q_idx]->txq.stats;
> + tx_stats = apc->tx_qp[q_idx]->txq.stats;
>
> u64_stats_update_begin(&tx_stats->syncp);
> tx_stats->xdp_xmit += count;
> u64_stats_update_end(&tx_stats->syncp);
[Severity: Medium]
Can this result in lost statistic increments due to a data race?
When multiple CPUs perform XDP redirects to the same queue, they will execute
mana_xdp_xmit() concurrently. Because tx_stats->xdp_xmit is updated outside
of lock protection, the non-atomic addition operations can collide and
cause lost increments.
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index 45cb23717151f..02cd5f7656ed8 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
[ ... ]
> @@ -4491,6 +4557,7 @@ void mana_remove(struct gdma_dev *gd, bool suspending)
>
> unregister_netdevice(ndev);
> mana_cleanup_indir_table(apc);
> + mana_free_queue_stats(apc);
>
> /* Remove the port from reset walks before freeing its netdev.
> */
[Severity: High]
Does this create a use-after-free race with lockless readers like
mana_get_stats64()?
When mana_remove() calls unregister_netdevice(), the synchronize_net()
call is deferred until rtnl_unlock() happens later. Because
mana_free_queue_stats() is called here before the RCU grace period completes,
concurrent readers querying the device could dereference the freed
apc->rxq_stats and apc->txq_stats pointers.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1790795005.git.weh@linux.microsoft.com?part=3
next prev parent reply other threads:[~2026-10-10 14:42 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 14:41 [PATCH net-next v6 00/13] net: mana: reconfigure by replacing the queue set Wei Hu
2026-10-09 14:41 ` [PATCH net-next v6 01/13] net: mana: add queue-set allocation and teardown helpers Wei Hu
2026-10-10 14:42 ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 02/13] net: mana: share the EQ pool across a queue-set swap Wei Hu
2026-10-10 14:42 ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 03/13] net: mana: keep per-queue statistics in the port context Wei Hu
2026-10-10 14:42 ` sashiko-bot [this message]
2026-10-13 10:26 ` [EXTERNAL] " Wei Hu
2026-10-09 14:41 ` [PATCH net-next v6 04/13] net: mana: swap queue sets in mana_set_channels Wei Hu
2026-10-10 14:42 ` sashiko-bot
2026-10-13 10:39 ` [EXTERNAL] " Wei Hu
2026-10-09 14:41 ` [PATCH net-next v6 05/13] net: mana: swap queue sets in mana_set_ringparam Wei Hu
2026-10-10 14:42 ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 06/13] net: mana: swap queue sets in mana_set_priv_flags Wei Hu
2026-10-10 14:42 ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 07/13] net: mana: swap queue sets in mana_change_mtu Wei Hu
2026-10-10 14:42 ` sashiko-bot
2026-10-13 11:11 ` [EXTERNAL] " Wei Hu
2026-10-09 14:41 ` [PATCH net-next v6 08/13] net: mana: swap queue sets in mana_xdp_set Wei Hu
2026-10-10 14:42 ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 09/13] net: mana: do not bail out of mana_detach on dealloc failure Wei Hu
2026-10-10 14:42 ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 10/13] net: mana: release EQs left idle by a channel-count reduction Wei Hu
2026-10-10 14:42 ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 11/13] net: mana: keep a user-configured RSS table across a queue rebuild Wei Hu
2026-10-10 14:42 ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 12/13] net: mana: keep the surviving queues when the channel count is reduced Wei Hu
2026-10-10 14:42 ` sashiko-bot
2026-10-09 14:41 ` [PATCH net-next v6 13/13] net: mana: keep the existing queues when the channel count is raised Wei Hu
2026-10-10 14:42 ` sashiko-bot
2026-10-10 16:28 ` [PATCH net-next v6 00/13] net: mana: reconfigure by replacing the queue set Simon Horman
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=sashiko-outbox-166660@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=weh@linux.microsoft.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.