From: sashiko-bot@kernel.org
To: guohongyu <guohongyu@cmss.chinamobile.com>,
intel-wired-lan@lists.osuosl.org
Subject: Re: [PATCH] idpf: fix vport_id used as array index in MAC filter async handler
Date: Thu, 26 Nov 2026 05:04:18 +0000 [thread overview]
Message-ID: <sashiko-outbox-234759@kernel.org> (raw)
In-Reply-To: <20261126020854.233971-1-guohongyu@cmss.chinamobile.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] idpf: use-after-free of vport in
idpf_mac_filter_async_handler() on remove
--
commit 6b177b36cf8b8b2ad682680d9ce0837d77dda78f
Author: guohongyu <guohongyu@cmss.chinamobile.com>
idpf: fix vport_id used as array index in MAC filter async handler
This commit indexes adapter->vport_config[] by vport->idx instead of the
raw vport_id from the virtchnl payload in idpf_mac_filter_async_handler().
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> index dac1d9fc4ab12..7870e8f810fa9 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> @@ -3781,7 +3781,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 dereferencing vport->idx here cause a use-after-free of vport during
driver removal or shutdown?
CPU0 CPU1 (mbx_wq)
idpf_remove()
set_bit(IDPF_REMOVE_IN_PROG, ...)
idpf_vc_core_deinit()
queue_delayed_work(..., &mbx_task)
idpf_deinit_task()
idpf_vport_dealloc()
idpf_mac_filter_async_handler()
vport = idpf_vid_to_vport(...)
idpf_vport_rel()
kfree(vport)
vport->idx <-- use-after-free
adapter->vports[i] = NULL;
During removal, idpf_vc_core_deinit() keeps mbx_task running across
idpf_deinit_task() and relies on async callbacks to bail out when
IDPF_REMOVE_IN_PROG is set, as idpf_ptp_get_tx_tstamp_async_handler()
does. Because idpf_vport_dealloc() frees vport inside idpf_vport_rel()
before clearing adapter->vports[i], and nothing serializes it against
idpf_vid_to_vport(), an arriving MAC filter error reply can obtain a
dangling vport pointer and read vport->idx after vport is freed.
Checking test_bit(IDPF_REMOVE_IN_PROG, adapter->flags) at the start of
idpf_mac_filter_async_handler() would prevent the handler from running
while vports are being torn down.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126020854.233971-1-guohongyu@cmss.chinamobile.com?part=1
next prev parent reply other threads:[~2026-11-26 5:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261126020854.233971-1-guohongyu@cmss.chinamobile.com>
2026-11-26 2:18 ` [PATCH] idpf: fix vport_id used as array index in MAC filter async handler netdev-bot+sinfo
2026-11-26 5:04 ` sashiko-bot [this message]
2026-11-26 5:09 ` Przemek Kitszel
[not found] ` <20261126092627.255454-1-guohongyu@cmss.chinamobile.com>
2026-11-26 9:38 ` [PATCH v2] " netdev-bot+sinfo
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-234759@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=guohongyu@cmss.chinamobile.com \
--cc=intel-wired-lan@lists.osuosl.org \
--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