From: netdev-bot+sashiko@kernel.org
To: guohongyu@cmss.chinamobile.com
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, alan.brady@intel.com,
stable@vger.kernel.org, 13057616121@163.com
Subject: Re: [PATCH] idpf: fix vport_id used as array index in MAC filter async handler
Date: Fri, 27 Nov 2026 02:17:12 +0000 [thread overview]
Message-ID: <179574583226.3135.4850818709708500001@kernel.org> (raw)
In-Reply-To: <20261126020854.233971-1-guohongyu@cmss.chinamobile.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] Possible use-after-free introduced by the patch.
- [Low] The commit message describes only part of what the old code did
wrong.
--
idpf: fix vport_id used as array index in MAC filter async handler
This patch changes idpf_mac_filter_async_handler() so that it indexes
adapter->vport_config[] with the software slot index of the vport
returned by idpf_vid_to_vport(). Before, it used the raw device-side
vport_id from the virtchnl message, which could be out of range.
> vport_config[] has num_max_vports entries and vport_id is an opaque
> device-side identifier that the protocol does not bound by it, so
> a vport id not smaller than num_max_vports makes the handler read
> past the end of the array and use the garbage result as a
> struct idpf_vport_config (spinlock taken, filter list walked,
> entries list_del()'ed through out-of-bounds pointers).
[Severity: Low]
This isn't a bug, but could the changelog also cover the in-range
cases that the old code got wrong?
idpf_add_del_mac_filters() sends the device-side vport->vport_id.
idpf_vid_to_vport() maps it back to a slot by searching
adapter->vport_ids[]. So the device id and vport->idx are unrelated
values.
If the device id is below num_max_vports but names a slot that belongs
to another vport, the old code silently removed MAC filters from that
other vport's mac_filter_list.
If the device id names a slot that was never allocated, the entry is
NULL, because idpf_vport_alloc() fills vport_config[] lazily:
idpf_vport_alloc() {
...
adapter->vport_config[idx] = vport_config;
...
}
In that case spin_lock_bh(&vport_config->mac_filter_list_lock)
dereferences NULL.
The code change fixes all three cases; only the description is
incomplete. The wrong-vport filter deletion may be the symptom stable
backporters are most likely to recognise.
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> index c89783966bae3..2e173d0cb7e63 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> @@ -3852,7 +3852,7 @@ static void idpf_mac_filter_async_handler(void *ctx,
> if (!vport)
> goto invalid_payload;
>
> - vport_config = adapter->vport_config[le32_to_cpu(ma_list->vport_id)];
> + vport_config = adapter->vport_config[vport->idx];
[Severity: Medium]
Can this read vport->idx from a freed struct idpf_vport?
idpf_vid_to_vport() takes no lock, no RCU read lock and no reference:
for (i = 0; i < num_max_vports; i++)
if (adapter->vport_ids[i] == v_id)
return adapter->vports[i];
This handler runs from mbx_task, through libie_ctlq_xn_process_recv()
-> xn->resp_cb(). Only xn->xn_lock is held there, and teardown never
takes that lock.
On PCI remove, IDPF_REMOVE_IN_PROG is set. idpf_vc_core_deinit() then
frees the vports before it shuts down the transaction manager and
cancels mbx_task:
idpf_vc_core_deinit() {
...
idpf_deinit_task(adapter);
...
if (remove_in_prog)
libie_ctlq_xn_shutdown(adapter->xnm);
cancel_delayed_work_sync(&adapter->serv_task);
cancel_delayed_work_sync(&adapter->mbx_task);
...
}
idpf_deinit_task() -> idpf_vport_dealloc() -> idpf_vport_rel() does
kfree(vport). idpf_vport_dealloc() clears the slot only after that:
idpf_vport_rel(vport);
adapter->vports[i] = NULL;
An error response to an earlier ADD/DEL_MAC_ADDR request could arrive
in that window. The handler could then get the vport pointer just
before the kfree, or the stale pointer between the kfree and the NULL
store.
If that memory has been reused, idx is garbage. That gives an
out-of-bounds read of adapter->vport_config[], followed by
spin_lock_bh() and list_del() on wild memory.
The old code never dereferenced vport here. The vport_config[] entries
are freed only in idpf_remove(), after the workqueues are destroyed.
The window is narrow. idpf_vport_rel() sends destroy_vport
synchronously, so the race needs the control plane to answer a pending
MAC request after the destroy_vport response. The reset path is not
affected: there libie_ctlq_xn_shutdown() runs first and drops async
transactions without calling resp_cb.
Would it be safer to have the lookup return the slot index i instead?
adapter->vports[i] == vport implies i == vport->idx, and i is always
below num_max_vports. adapter->vport_config[i] could then be used
without reading through the vport pointer.
> ma_list_head = &vport_config->user_config.mac_filter_list;
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126020854.233971-1-guohongyu%40cmss.chinamobile.com
next prev parent reply other threads:[~2026-11-27 2:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 2:08 [PATCH] idpf: fix vport_id used as array index in MAC filter async handler guohongyu
2026-11-26 2:18 ` netdev-bot+sinfo
2026-11-26 2:35 ` guohongyu
2026-11-26 5:09 ` Przemek Kitszel
2026-11-26 9:26 ` [PATCH v2] " Hongyu Guo
2026-11-26 9:38 ` netdev-bot+sinfo
2026-11-27 2:17 ` netdev-bot+sashiko [this message]
2026-11-27 2:32 ` Hongyu Guo
2026-11-27 2:33 ` Hongyu Guo
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=179574583226.3135.4850818709708500001@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=13057616121@163.com \
--cc=alan.brady@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=guohongyu@cmss.chinamobile.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=stable@vger.kernel.org \
/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