From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Hongyu Guo <guohongyu@cmss.chinamobile.com>,
<netdev@vger.kernel.org>, <pabeni@redhat.com>
Cc: <anthony.l.nguyen@intel.com>, <andrew+netdev@lunn.ch>,
<intel-wired-lan@lists.osuosl.org>, <davem@davemloft.net>,
<edumazet@kernel.org>, <kuba@kernel.org>,
<stable@vger.kernel.org>, <13057616121@163.com>
Subject: Re: [PATCH v2] idpf: fix vport_id used as array index in MAC filter async handler
Date: Fri, 27 Nov 2026 09:44:52 +0100 [thread overview]
Message-ID: <43e42e0e-d099-47f0-a4ab-965b6e936a75@intel.com> (raw)
In-Reply-To: <20261126092627.255454-1-guohongyu@cmss.chinamobile.com>
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);
next prev parent reply other threads:[~2026-11-27 8:45 UTC|newest]
Thread overview: 10+ 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 8:44 ` Przemek Kitszel [this message]
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
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=43e42e0e-d099-47f0-a4ab-965b6e936a75@intel.com \
--to=przemyslaw.kitszel@intel.com \
--cc=13057616121@163.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=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