* Re: [PATCH] idpf: fix vport_id used as array index in MAC filter async handler
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
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: netdev-bot+sinfo @ 2026-11-26 2:18 UTC (permalink / raw)
To: guohongyu
Cc: intel-wired-lan, netdev, anthony.l.nguyen, przemyslaw.kitszel,
andrew+netdev, davem, edumazet, kuba, pabeni, alan.brady, stable,
13057616121
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH] idpf: fix vport_id used as array index in MAC filter async handler
2026-11-26 2:18 ` netdev-bot+sinfo
@ 2026-11-26 2:35 ` guohongyu
0 siblings, 0 replies; 11+ messages in thread
From: guohongyu @ 2026-11-26 2:35 UTC (permalink / raw)
To: netdev
Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel,
andrew+netdev, davem, edumazet, kuba, pabeni, alan.brady, stable,
13057616121
Answers to the three questions:
- How the issue was discovered: manual code inspection. The handler
was found during a code audit of the idpf virtchnl receive paths;
the bug is visible by reading the function: it resolves the vport
with idpf_vid_to_vport() and then does not use it, indexing
vport_config[] with the raw vport_id instead, unlike every other
call site in the driver.
- Whether the issue was actually triggered: no, it is not proven at
runtime. The out-of-bounds path requires a control plane that hands
out a vport id not smaller than num_max_vports and then reports a
failing ADD/DEL_MAC_ADDR status for it; no hardware was available to
exercise this, so the issue is theoretical, found by inspection.
- Testing: no real hardware available. The change is a one-line
substitution of an array index; it was compile-tested with
CONFIG_IDPF=m (x86_64, gcc 12), builds without new warnings.
Thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] idpf: fix vport_id used as array index in MAC filter async handler
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 5:09 ` Przemek Kitszel
2026-11-26 9:26 ` [PATCH v2] " Hongyu Guo
2026-11-27 2:17 ` [PATCH] " netdev-bot+sashiko
3 siblings, 0 replies; 11+ messages in thread
From: Przemek Kitszel @ 2026-11-26 5:09 UTC (permalink / raw)
To: guohongyu, intel-wired-lan, netdev
Cc: anthony.l.nguyen, andrew+netdev, davem, edumazet, kuba, pabeni,
13057616121
On 11/26/26 3:08 AM, guohongyu wrote:
> idpf_mac_filter_async_handler() resolves the vport for an incoming
> ADD/DEL_MAC_ADDR async response with idpf_vid_to_vport(), but then
> ignores the resolved vport and indexes adapter->vport_config[]
> directly with the raw 32-bit vport_id from the virtchnl message.
> 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).
>
> Fix this by using the software index of the already-resolved vport,
> adapter->vport_config[vport->idx], as every other call site in the
> driver already does. The index comes from the vport allocation
> slot and is always in range.
>
> Fixes: 41252855df77 ("idpf: add async_handler for MAC filter messages")
> Cc: stable@vger.kernel.org
> Signed-off-by: guohongyu <guohongyu@cmss.chinamobile.com>
Thank you for the patch.
For kernel contributions there is expectation to use Firstname Surname
format, could you please update?
Regarding the code, at first glance it's indeed good direction, but
as this is async handler, all kinds of ugly problems could pop up,
as reported by sashiko. Basically, it races with driver removal:
https://sashiko.dev/#/patchset/20261126020854.233971-1-guohongyu%40cmss.chinamobile.com
> ---
> drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> index 1caf52706973..e72877242612 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> @@ -3794,7 +3794,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];
> ma_list_head = &vport_config->user_config.mac_filter_list;
>
> /* We can't do much to reconcile bad filters at this point, however we
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v2] idpf: fix vport_id used as array index in MAC filter async handler
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 5:09 ` Przemek Kitszel
@ 2026-11-26 9:26 ` Hongyu Guo
2026-11-26 9:38 ` netdev-bot+sinfo
` (2 more replies)
2026-11-27 2:17 ` [PATCH] " netdev-bot+sashiko
3 siblings, 3 replies; 11+ messages in thread
From: Hongyu Guo @ 2026-11-26 9:26 UTC (permalink / raw)
To: intel-wired-lan, netdev
Cc: anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev, davem,
edumazet, kuba, pabeni, alan.brady, stable, 13057616121
idpf_mac_filter_async_handler() looks up the vport with
idpf_vid_to_vport(), but then indexes adapter->vport_config[] with
the raw vport_id from the message instead of using the vport it
just found. vport_id is a device-assigned 32-bit number and is
not limited to num_max_vports, so vport_config[vport_id] can read
past the end of the array. Use vport->idx, the array index the
rest of the driver uses.
During driver removal the vports are freed before the mailbox
work is cancelled, so this handler can still run while a vport it
looks up is being freed. Return early if IDPF_REMOVE_IN_PROG is
set.
The filter removal loop in the same handler also leaks: it does
list_del() without kfree(), and if the response lists the same MAC
more than once it deletes the same entry twice. Free the filter
and break out of the inner loop once it is removed.
Fixes: 41252855df77 ("idpf: add async_handler for MAC filter messages")
Cc: stable@vger.kernel.org
Signed-off-by: Hongyu Guo <guohongyu@cmss.chinamobile.com>
---
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
index 1caf52706973..ff43a3d34eac 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
@@ -3779,6 +3779,10 @@ static void idpf_mac_filter_async_handler(void *ctx,
if (!status || status == -ETIMEDOUT)
return;
+ /* vports are freed during removal, before this work is cancelled */
+ if (test_bit(IDPF_REMOVE_IN_PROG, adapter->flags))
+ return;
+
ma_list = buff->iov_base;
/* make sure at least struct is there */
if (buff->iov_len < sizeof(*ma_list))
@@ -3794,7 +3798,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];
ma_list_head = &vport_config->user_config.mac_filter_list;
/* We can't do much to reconcile bad filters at this point, however we
@@ -3804,8 +3808,11 @@ static void idpf_mac_filter_async_handler(void *ctx,
spin_lock_bh(&vport_config->mac_filter_list_lock);
list_for_each_entry_safe(f, tmp, ma_list_head, list)
for (i = 0; i < num_entries; i++)
- if (ether_addr_equal(mac_addr[i].addr, f->macaddr))
+ if (ether_addr_equal(mac_addr[i].addr, f->macaddr)) {
list_del(&f->list);
+ kfree(f);
+ break;
+ }
spin_unlock_bh(&vport_config->mac_filter_list_lock);
dev_err_ratelimited(&adapter->pdev->dev, "Received error %d on sending MAC filter request\n",
status);
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2] idpf: fix vport_id used as array index in MAC filter async handler
2026-11-26 9:26 ` [PATCH v2] " Hongyu Guo
@ 2026-11-26 9:38 ` netdev-bot+sinfo
2026-11-27 8:44 ` Przemek Kitszel
2026-11-27 9:35 ` netdev-bot+sashiko
2 siblings, 0 replies; 11+ messages in thread
From: netdev-bot+sinfo @ 2026-11-26 9:38 UTC (permalink / raw)
To: Hongyu Guo
Cc: intel-wired-lan, netdev, anthony.l.nguyen, przemyslaw.kitszel,
andrew+netdev, davem, edumazet, kuba, pabeni, alan.brady, stable,
13057616121
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] idpf: fix vport_id used as array index in MAC filter async handler
2026-11-26 9:26 ` [PATCH v2] " Hongyu Guo
2026-11-26 9:38 ` netdev-bot+sinfo
@ 2026-11-27 8:44 ` Przemek Kitszel
2026-11-27 9:35 ` netdev-bot+sashiko
2 siblings, 0 replies; 11+ messages in thread
From: Przemek Kitszel @ 2026-11-27 8:44 UTC (permalink / raw)
To: Hongyu Guo, netdev, pabeni
Cc: anthony.l.nguyen, andrew+netdev, intel-wired-lan, davem, edumazet,
kuba, stable, 13057616121
On 11/26/26 10:26 AM, Hongyu Guo wrote:
> idpf_mac_filter_async_handler() looks up the vport with
> idpf_vid_to_vport(), but then indexes adapter->vport_config[] with
> the raw vport_id from the message instead of using the vport it
> just found. vport_id is a device-assigned 32-bit number and is
> not limited to num_max_vports, so vport_config[vport_id] can read
> past the end of the array. Use vport->idx, the array index the
> rest of the driver uses.
>
> During driver removal the vports are freed before the mailbox
> work is cancelled, so this handler can still run while a vport it
> looks up is being freed. Return early if IDPF_REMOVE_IN_PROG is
> set.
>
> The filter removal loop in the same handler also leaks: it does
> list_del() without kfree(), and if the response lists the same MAC
> more than once it deletes the same entry twice. Free the filter
> and break out of the inner loop once it is removed.
>
> Fixes: 41252855df77 ("idpf: add async_handler for MAC filter messages")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hongyu Guo <guohongyu@cmss.chinamobile.com>
thank you for v2, next time please post as a new thread, instead of
in-reply-to v1
here would be also good place to put changelog/link to v1
(under additional "---")
no need to repost for any of that (as long as Paolo will merge this :))
Acked-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> ---
> drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> index 1caf52706973..ff43a3d34eac 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> @@ -3779,6 +3779,10 @@ static void idpf_mac_filter_async_handler(void *ctx,
> if (!status || status == -ETIMEDOUT)
> return;
>
> + /* vports are freed during removal, before this work is cancelled */
> + if (test_bit(IDPF_REMOVE_IN_PROG, adapter->flags))
> + return;
> +
> ma_list = buff->iov_base;
> /* make sure at least struct is there */
> if (buff->iov_len < sizeof(*ma_list))
> @@ -3794,7 +3798,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];
> ma_list_head = &vport_config->user_config.mac_filter_list;
>
> /* We can't do much to reconcile bad filters at this point, however we
> @@ -3804,8 +3808,11 @@ static void idpf_mac_filter_async_handler(void *ctx,
> spin_lock_bh(&vport_config->mac_filter_list_lock);
> list_for_each_entry_safe(f, tmp, ma_list_head, list)
> for (i = 0; i < num_entries; i++)
> - if (ether_addr_equal(mac_addr[i].addr, f->macaddr))
> + if (ether_addr_equal(mac_addr[i].addr, f->macaddr)) {
> list_del(&f->list);
> + kfree(f);
> + break;
> + }
> spin_unlock_bh(&vport_config->mac_filter_list_lock);
> dev_err_ratelimited(&adapter->pdev->dev, "Received error %d on sending MAC filter request\n",
> status);
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v2] idpf: fix vport_id used as array index in MAC filter async handler
2026-11-26 9:26 ` [PATCH v2] " Hongyu Guo
2026-11-26 9:38 ` netdev-bot+sinfo
2026-11-27 8:44 ` Przemek Kitszel
@ 2026-11-27 9:35 ` netdev-bot+sashiko
2 siblings, 0 replies; 11+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 9:35 UTC (permalink / raw)
To: guohongyu
Cc: intel-wired-lan, netdev, anthony.l.nguyen, przemyslaw.kitszel,
andrew+netdev, davem, edumazet, kuba, pabeni, alan.brady, stable,
13057616121
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 (1) · Medium: 0 · Low: 0
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).
- [High] The new `test_bit(IDPF_REMOVE_IN_PROG)` check in
idpf_mac_filter_async_handler()…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the commit
message's own reasoning ('during driver removal the vports are freed…
--
idpf: fix vport_id used as array index in MAC filter async handler
This commit changes idpf_mac_filter_async_handler() so that it indexes
adapter->vport_config[] with vport->idx instead of the raw vport_id from
the message. It also returns early if IDPF_REMOVE_IN_PROG is set. It fixes
the filter removal loop so that removed entries are freed and never
deleted twice.
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> index c89783966bae3..4ffb8f9df2797 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> @@ -3837,6 +3837,10 @@ static void idpf_mac_filter_async_handler(void *ctx,
> if (!status || status == -ETIMEDOUT)
> return;
>
> + /* vports are freed during removal, before this work is cancelled */
> + if (test_bit(IDPF_REMOVE_IN_PROG, adapter->flags))
> + return;
> +
> ma_list = buff->iov_base;
> /* make sure at least struct is there */
> if (buff->iov_len < sizeof(*ma_list))
[ ... ]
> @@ -3852,7 +3856,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: High]
Does the IDPF_REMOVE_IN_PROG check close the removal race described in the
commit message? The test_bit() is a lockless snapshot. Nothing keeps the
vport alive once the check has passed.
The handler runs from mbx_task, and the only lock held is xn->xn_lock:
idpf_mbx_task()
libie_ctlq_xn_recv()
libie_ctlq_xn_process_recv()
xn->resp_cb() -> idpf_mac_filter_async_handler()
If the handler sees the bit clear, idpf_remove() can set it right after
and carry on:
idpf_remove()
set_bit(IDPF_REMOVE_IN_PROG, adapter->flags);
idpf_vc_core_deinit()
idpf_deinit_task()
idpf_vport_dealloc()
idpf_vport_rel()
kfree(vport);
adapter->vports[i] = NULL;
idpf_vid_to_vport() reads adapter->vports[i] without a lock. It can
therefore return a vport that has already been freed but whose slot has
not been cleared yet. The new vport->idx read would then come from freed
memory. The spin_lock_bh(), list_del() and kfree(f) that follow would act
on whatever vport_config that stale index selects.
Before this patch, the handler only NULL-checked vport and never
dereferenced it.
Normally the synchronous DESTROY_VPORT in idpf_vport_rel() bounds this
window, because only mbx_task completes sync transactions. But there are
two cases where teardown doesn't wait on mbx_task:
- idpf_send_mb_msg() returns -EBUSY right away when
idpf_is_reset_detected() is true.
- libie_ctlq_xn_send() can fail fast with -EAGAIN when no xn is free.
On PREEMPT_RT, or under vCPU preemption, the handler can also stall between
the test_bit() and the vport->idx read.
Could the handler avoid touching the vport at all? idpf_vid_to_vport()
already finds the slot i where adapter->vport_ids[i] == v_id, and
vport->idx == i. adapter->vport_config[i] stays allocated until after
mbx_task is cancelled. Using the matched slot index would fix the out of
bounds read without needing the flag check.
Another option is to shut down xn and flush mbx_task before the vports are
freed.
[Severity: High]
This isn't a bug introduced by this patch, but the commit message's
reasoning ("During driver removal the vports are freed before the mailbox
work is cancelled") applies equally to idpf_handle_event_link(). That
handler runs from the same mbx_task, via idpf_recv_event_msg(), for
VIRTCHNL2_EVENT_LINK_CHANGE:
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:idpf_handle_event_link() {
vport = idpf_vid_to_vport(adapter, le32_to_cpu(v2e->vport_id));
...
np = netdev_priv(vport->netdev);
np->link_speed_mbps = le32_to_cpu(v2e->link_speed);
...
vport->link_up = v2e->link_status;
...
}
In idpf_vport_dealloc(), idpf_decfg_netdev() frees the netdev and sets
vport->netdev = NULL. adapter->vports[i] stays published until
idpf_vport_rel() returns:
drivers/net/ethernet/intel/idpf/idpf_lib.c:idpf_vport_dealloc() {
...
idpf_decfg_netdev(vport);
...
idpf_vport_rel(vport);
adapter->vports[i] = NULL;
...
}
That window includes the synchronous DESTROY_VPORT round trip, and mbx_task
keeps dispatching ARQ events during it.
Could a link change event processed in that window hit netdev_priv(NULL)
and oops on the np->link_speed_mbps write? If the event arrives after
kfree(vport) in idpf_vport_rel(), the vport->link_up write would also land
in freed memory.
Neither idpf_mbx_task() nor idpf_recv_event_msg() checks
IDPF_REMOVE_IN_PROG. Copying the test_bit() check here would leave the same
race as above.
Either of these might cover both handlers:
- clear adapter->vports[i] before tearing down the netdev and the vport
- stop mbx event dispatch before the vports are freed
> ma_list_head = &vport_config->user_config.mac_filter_list;
>
> /* We can't do much to reconcile bad filters at this point, however we
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126092627.255454-1-guohongyu%40cmss.chinamobile.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] idpf: fix vport_id used as array index in MAC filter async handler
2026-11-26 2:08 [PATCH] idpf: fix vport_id used as array index in MAC filter async handler guohongyu
` (2 preceding siblings ...)
2026-11-26 9:26 ` [PATCH v2] " Hongyu Guo
@ 2026-11-27 2:17 ` netdev-bot+sashiko
2026-11-27 2:32 ` [PATCH v2] " Hongyu Guo
2026-11-27 2:33 ` Hongyu Guo
3 siblings, 2 replies; 11+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 2:17 UTC (permalink / raw)
To: guohongyu
Cc: intel-wired-lan, netdev, anthony.l.nguyen, przemyslaw.kitszel,
andrew+netdev, davem, edumazet, kuba, pabeni, alan.brady, stable,
13057616121
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
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v2] idpf: fix vport_id used as array index in MAC filter async handler
2026-11-27 2:17 ` [PATCH] " netdev-bot+sashiko
@ 2026-11-27 2:32 ` Hongyu Guo
2026-11-27 2:33 ` Hongyu Guo
1 sibling, 0 replies; 11+ messages in thread
From: Hongyu Guo @ 2026-11-27 2:32 UTC (permalink / raw)
To: netdev
Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel, alan.brady,
13057616121
The Medium finding is real and already addressed in v2, which was
posted before this review ran: the handler now returns early when
IDPF_REMOVE_IN_PROG is set, before it looks up or touches any vport.
The Low finding is also correct. The old code did not just read out
of bounds: when the device-side id was in range but did not match
its own slot, it removed the filters from the wrong vport's list,
and when the id pointed at a slot that was never allocated,
vport_config[] was NULL and the handler dereferenced it. v3 will
add these cases to the changelog.
Returning the slot index from the lookup instead of dereferencing
vport would close the remaining window between the REMOVE_IN_PROG
check and the vport->idx read. I can switch to that if preferred.
pw-bot: cr
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] idpf: fix vport_id used as array index in MAC filter async handler
2026-11-27 2:17 ` [PATCH] " netdev-bot+sashiko
2026-11-27 2:32 ` [PATCH v2] " Hongyu Guo
@ 2026-11-27 2:33 ` Hongyu Guo
1 sibling, 0 replies; 11+ messages in thread
From: Hongyu Guo @ 2026-11-27 2:33 UTC (permalink / raw)
To: netdev
Cc: intel-wired-lan, anthony.l.nguyen, przemyslaw.kitszel, alan.brady,
13057616121
The Medium finding is real and already addressed in v2, which was
posted before this review ran: the handler now returns early when
IDPF_REMOVE_IN_PROG is set, before it looks up or touches any vport.
The Low finding is also correct. The old code did not just read out
of bounds: when the device-side id was in range but did not match
its own slot, it removed the filters from the wrong vport's list,
and when the id pointed at a slot that was never allocated,
vport_config[] was NULL and the handler dereferenced it. v3 will
add these cases to the changelog.
Returning the slot index from the lookup instead of dereferencing
vport would close the remaining window between the REMOVE_IN_PROG
check and the vport->idx read. I can switch to that if preferred.
pw-bot: cr
^ permalink raw reply [flat|nested] 11+ messages in thread