Article View: linux.kernel.netdev
Article #23292Re: [PATCH] idpf: fix vport_id used as array index in MAC filter async handler
From: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 02:17
Date: Fri, 27 Nov 2026 02:17
135 lines
12981 bytes
12981 bytes
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
Technical Details
Message-ID:
<179574583226.3135.4850818709708500001@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372410-linux-kernel-netdev=dewy.ruReferences:
<20261126020854.233971-1-guohongyu@cmss.chinamobile.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372410-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <179574583226.3135.4850818709708500001@kernel.org> References: <20261126020854.233971-1-guohongyu@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="617106"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:ofxsMykZ0CwyvgHoGr545O0RmuI= sha256:Cu0VPeGlCqkAjBKgor9XWPtBKyUju7LUNvlggggoOdk= sha1:hsLmoCjcTdYGtyF72SrxG+W+2SQ= sha256:BpkZV7nBGPjWw40xWtg9LD20eW5eUL+KW5tdjq1rl4o= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 927DD125F0D; Fri, 27 Nov 2026 05:17:35 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NmUPk8IgUXTN; Fri, 27 Nov 2026 05:17:27 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-372410-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 8931C125F0C; Fri, 27 Nov 2026 05:17:18 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id EAC88607FBB; Fri, 27 Nov 2026 02:17:17 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795745835; b=4fbspjzbxUC1wdS59f6VMwkMPqEXAjUj8K2EK/LQkgc8rly2A2BzY2m2ZYFAGBYw2qF5 56Ux5Nxe6XY7isxcJ94TljH791E1yh1NOQ2eQZjelumHOWFjtetDejTTxnwu2LWmdljyl A2qa3iqTNRBzip0wAT3Yjs0l7vkCPkFou4lswWcJ/eaP1qDdtkU+Mn4wdxGO4yl+Y2s2n Sxe0IW+8bt68bcz2x+CgNit41m7R27qMwS5xG9UMPZDM6+XzxD4yW4aOfsD8a2fg8RBsZ 9DsOjeS4pLiwMsZgubUuJ1ST/ZNB3g/GMDXX3lM1q0BVLbYJ5TEQPbQIemxVU1lX+ZQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795745835; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=eptb+3/EXFgZ8fNsxkLPAmXNUSDaiv1rQ2/GDYvfOYo=; b=2bQlflOKLm4MUlNX8YqCWCt38HzqwvpfwIttGxbi4vjM7XzH5LDz1xegKTDewLCiJRmi q0ncGipC9zUZ6RfcB7Dk1KeMDIcNksukyLyzsMIQFFPi5obN8OTmrtL9XVYMtpg8m4gs1 yqaaZQL08Om2YzsS1wsAfjy1fHWkYzPq7Oiis18stly+LLZE8hjLK9TuA/RDNHOru2pvm v7bAE9VHR67Q3/hN8TkwztGx8TB0/o38MD9+caEKpwgrCUrT5a9ICQU/oW3Om5sZ0RYxF ArYBMEl52KhHm6rGr7VzW4OogygnfllQ2nQL0YLwSLPtBMyKTqFUhsECUdffkWNHpug== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cRsdNLrU; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C01F606A32A; Fri, 27 Nov 2026 02:17:15 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cRsdNLrU X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795745834; b=XwRmyo/xx5FdYxxUupGh5Q3GAemi9XHnDOyfGz9X811iD6gLbNEdJvxlM9sVWazC+Rd4 YtlZ8EyZjEt1Hx0eTHB8laHyRoIJMvxTIqFVHgeBq8RLVRC4NcUzz6IRCAT3x63C8yGw9 A5NF0X5Wr1Mz5mvEwNjsNpwmYxGvEq3+cAxVRETCRNAvYXSMh0uVCi7gTkjNVM/DGl7P/ x0ci73Rg7UllwrpPx8JCoQzFkCJLNThTP1ppNRe7WKked7KT+upCgzo/6ppe9jB1LTgjU chlOy8O+ITvsn7cp5EwotJbFRkdma07sKfD0bEjpE1qd2yrvXonoBa3l7Ov+D4R5xQg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795745834; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=eptb+3/EXFgZ8fNsxkLPAmXNUSDaiv1rQ2/GDYvfOYo=; b=gpb0GsiAVdr9K/8JHV+OHibNfgFe4k34KzWUeTIxYpO6H+Y6f+/fFOzyASX0mP+waPdV S3sl/4N7/auA0lYnUP3Lgd13OneogQ+MHPseH/+VEPy2O77n0MRZC9WnMS7/fzVMT47Ma sTSRuV8/7nSFO4ID9tDVmkoTpw2IiFW4gw17ADTihwiyI8X0FObQWj73x6kEugLY92XFk wfXCxpCVpN7Q44l2/monsXKvGs6Fj6KH+ol2JWkE5vwavF7mq4LdP4ExuxcqaIMJSmOlm q/IM7vueeLH2vWQeblYqIB/t1aCi53rLGf3BWyS+Hwu+CvK5UZjYCkuFli5kI/5nfdA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cRsdNLrU; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 593AE606A31C; Fri, 27 Nov 2026 02:17:14 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD2201F000C1; Fri, 27 Nov 2026 02:17:12 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795745833; bh=eptb+3/EXFgZ8fNsxkLPAmXNUSDaiv1rQ2/GDYvfOYo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=cRsdNLrUE3TIH7Gr+dgyRG8Zr6D8952UklD7szq0nbnCzXtNCWRkkv7BVP2taKsGc MnAAhopToZ2bzEyk5UD+3v7pYvg8eGPoLCasum3sSh3UMM6aUDaatnP3enyNR1LL3L +K5gV2ZbC3sT74xYIA3xY5fIYMTX6DerIhHsMZQ5RgOWhJEiTsoaUZP/7FzMd9x154 wAQtmII2yVHPFFiw8fVCSG7+bmG0kwgtsrm1FD1y4jFwYiQZLUsvLzomDVmpagpBPe xoJN2tlWqUVnQ1xd7hAIfD9Mzqp1DKqMvY6Rg5gQb1AoSb/u/IcdL287q9lnxjYrmf 3rX2QXPpHCF4Q== X-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 X-In-Reply-To: <20261126020854.233971-1-guohongyu@cmss.chinamobile.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list