* [PATCH] idpf: fix vport_id used as array index in MAC filter async handler
@ 2026-11-26 2:08 guohongyu
2026-11-26 2:18 ` netdev-bot+sinfo
2026-11-26 9:26 ` [PATCH v2] " Hongyu Guo
0 siblings, 2 replies; 5+ messages in thread
From: guohongyu @ 2026-11-26 2:08 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() 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>
---
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
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ 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 2:35 ` guohongyu
2026-11-26 9:26 ` [PATCH v2] " Hongyu Guo
1 sibling, 1 reply; 5+ 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] 5+ 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; 5+ 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] 5+ 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 9:26 ` Hongyu Guo
2026-11-26 9:38 ` netdev-bot+sinfo
1 sibling, 1 reply; 5+ 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] 5+ 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
0 siblings, 0 replies; 5+ 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] 5+ messages in thread
end of thread, other threads:[~2026-11-26 9:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 9:26 ` [PATCH v2] " Hongyu Guo
2026-11-26 9:38 ` netdev-bot+sinfo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox