From: sashiko-bot@kernel.org
To: "Long Li" <longli@microsoft.com>
Cc: linux-rdma@vger.kernel.org, linux-hyperv@vger.kernel.org
Subject: Re: [PATCH net-next v5 08/13] net: mana: do not bail out of mana_detach on dealloc failure
Date: Thu, 10 Sep 2026 22:25:18 +0000 [thread overview]
Message-ID: <20260910222519.53AAB1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260909222416.884246-9-longli@microsoft.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Dereferencing IP and IPv6 headers without ensuring they are in the linear region of the socket buffer.
- [Medium] Concurrent writers to `tx_stats->syncp` without mutual exclusion in `mana_xdp_xmit`.
--
commit 2b1d4ae0b77c96383014b2acf0502fef542484c7
Author: Dipayaan Roy <dipayanroy@linux.microsoft.com>
net: mana: do not bail out of mana_detach on dealloc failure
Remove the early return after mana_dealloc_queues() so detach continues
its device and port-context cleanup. The return is currently unreachable:
mana_dealloc_queues() only rejects an up port, and mana_detach() clears
port_is_up before calling it. This is a robustness cleanup, not a fix for
a reachable reset failure.
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index 62c11af2fc422..5752e3745ccc6 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
> @@ -4340,10 +4340,8 @@ int mana_detach(struct net_device *ndev, bool from_close)
>
> if (apc->port_st_save) {
> err = mana_dealloc_queues(ndev);
> - if (err) {
> + if (err)
> netdev_err(ndev, "%s failed to deallocate queues: %d\n", __func__, err);
> - return err;
> - }
> }
>
> if (!from_close) {
[ ... ]
> --- a/drivers/net/ethernet/microsoft/mana/mana_bpf.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_bpf.c
> @@ -76,9 +76,9 @@ int mana_xdp_xmit(struct net_device *ndev, int n, struct xdp_frame **frames,
> }
>
> 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]
This is a pre-existing issue, but does mana_xdp_xmit() safely update
the stats sync seqcount without mutual exclusion?
The u64_stats_sync API requires writers to be mutually exclusive per syncp
instance. Here, q_idx is calculated as
smp_processor_id() % ndev->real_num_tx_queues, and tx_stats->syncp is
updated without holding __netif_tx_lock.
Because q_idx can be targeted by normal stack TX via
skb_get_queue_mapping(skb), could another CPU concurrently execute
mana_start_xmit() for the same queue (which correctly holds
__netif_tx_lock and updates tx_stats->syncp)?
Also, if there are more online CPUs than configured TX queues, could
multiple CPUs running mana_xdp_xmit() map to the same q_idx and execute
u64_stats_update_begin() simultaneously?
This concurrent write access violates the u64_stats_sync writer rules,
which can corrupt the sequence counter and cause lost or torn updates.
[ ... ]
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
> @@ -167,7 +167,7 @@ static unsigned int mana_checksum_info(struct sk_buff *skb)
> {
> if (skb->protocol == htons(ETH_P_IP)) {
> struct iphdr *ip = ip_hdr(skb);
>
> if (ip->protocol == IPPROTO_TCP)
[Severity: High]
This isn't a bug introduced by this patch, but does this code safely
dereference the IP and IPv6 headers without ensuring they are in the linear
region of the socket buffer?
In mana_start_xmit(), if skb->ip_summed == CHECKSUM_PARTIAL, it calls
mana_checksum_info(skb). This function directly calls ip_hdr(skb) and
ipv6_hdr(skb), and immediately dereferences ip->protocol and ip6->nexthdr
without calling pskb_may_pull() or using skb_header_pointer().
Since packet headers injected from userspace (e.g. via AF_PACKET/tun with
virtio_net_hdr) can place the IP header entirely in paged fragments rather
than the linear data area (skb->data), couldn't failing to linearize the
header before dereferencing risk reading garbage data or causing
out-of-bounds page faults?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909222416.884246-1-longli@microsoft.com?part=8
next prev parent reply other threads:[~2026-09-10 22:25 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 22:24 [PATCH net-next v5 00/13] net: mana: reconfigure by replacing the queue set Long Li
2026-09-09 22:24 ` [PATCH net-next v5 01/13] net: mana: add queue-set allocation and teardown helpers Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 02/13] net: mana: share the EQ pool across a queue-set swap Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 03/13] net: mana: swap queue sets in mana_set_channels Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 04/13] net: mana: swap queue sets in mana_set_ringparam Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 05/13] net: mana: swap queue sets in mana_set_priv_flags Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 06/13] net: mana: swap queue sets in mana_change_mtu Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 07/13] net: mana: swap queue sets in mana_xdp_set Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 08/13] net: mana: do not bail out of mana_detach on dealloc failure Long Li
2026-09-10 22:25 ` sashiko-bot [this message]
2026-09-09 22:24 ` [PATCH net-next v5 09/13] net: mana: keep per-queue statistics in the port context Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 10/13] net: mana: release EQs left idle by a channel-count reduction Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 11/13] net: mana: keep a user-configured RSS table across a queue rebuild Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 12/13] net: mana: keep the surviving queues when the channel count is reduced Long Li
2026-09-10 22:25 ` sashiko-bot
2026-09-09 22:24 ` [PATCH net-next v5 13/13] net: mana: keep the existing queues when the channel count is raised Long Li
2026-09-10 22:25 ` sashiko-bot
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=20260910222519.53AAB1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=sashiko-reviews@lists.linux.dev \
/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