Article View: linux.kernel.netdev
Article #23436Re: [PATCH v2] idpf: fix vport_id used as array index in MAC filter async handler
From: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 09:35
Date: Fri, 27 Nov 2026 09:35
166 lines
13924 bytes
13924 bytes
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
Technical Details
Message-ID:
<179577213934.3135.4441263933524263637@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372584-linux-kernel-netdev=dewy.ruReferences:
<20261126092627.255454-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!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372584-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH v2] idpf: fix vport_id used as array index in MAC filter async handler Date: Fri, 27 Nov 2026 09:35:39 +0000 Organization: Usenet Network Message-ID: <179577213934.3135.4441263933524263637@kernel.org> References: <20261126092627.255454-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="696145"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Cf0P/WM4hsmBhNqj/OkJCgXIXdU= sha256:6DwvBHrO177dhbspMkeUxastFwZqvFkxXphEQDyuEgU= sha1:NhlD5aquu4ZWaAKRDUUVEo6QPes= sha256:k6+k0cl8MlGPXzRwbXmuREtpFLsWI2rseKwI/GCHOYM= 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 65D4A125F39; Fri, 27 Nov 2026 12:36:00 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, 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 aCwvlxpF_gNt; Fri, 27 Nov 2026 12:35:56 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-372584-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id F3F5E125F36; Fri, 27 Nov 2026 12:35:45 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id E222C2FB20; Fri, 27 Nov 2026 09:35:42 +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=1795772142; b=rymZHs6LQcVxvJNpDowyEPzCblBUWjkM0fabExXtkEVHPWNy+CI04jrGnwmR/3Z3YMb1 xd8XTL8Kp2KNVzwKQ4opQO9z5gXoL8Vt8My/Oh6gTUJoBSXJo3qCjf+XP1wA7dHR8bquz eHzzQSpiNz2PUUth1rojkdWiFV1wdX3X8Z7Y1flnSLLm6ubsET3WhUUIPHM0QTbbGJLSy vsOkG0eP9O9nWsmIOhddEDmcN8kt9+wyZd39QMBeFk67nqmpGt8yTdVKkesLkJHq4twaw DvNUojV95ybkSC++Ye576gUsZhtZ6ycstppT3yGVqQb64RNxiRramPzBE+vcyodal+g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795772142; 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=hwQ67UPDDBpBlNdOHdQzfI33A0euocSSF71ObVKBPMQ=; b=HaBcidGWo8AfUijsxn6U7XGaxDa1/GyG8dzTBVTusw64/Rka5ERH9Zw7IiarQNBHoWmK u0lZ9M9uxJzb4PZJEGUSdP7Gu+7J5YmU6vb9/JBd+xb/JlCFvYtrXCHjmSBxTYqbyw41H sFcVbEWXkw6WmKE0tZEaMGmwWjPR3EqS4z+gZArclSJa3n+uN2cnelZV3F6BiNAIPfU56 lZBZVrK3i62bxubF2SiCRBxmHiCJpFBw8OKozouGvPVp6TLCsYzkAAXTKystBUr5iXC6o CwOOjujKUsJrXRwkYI1FOpH1uWL2330XuONOHLN+htvJmxgzaWsiEMSQszYefGfZbEg== 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=KT02Zom2; 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 31E19606A327; Fri, 27 Nov 2026 09:35:42 +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=KT02Zom2 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=1795772141; b=V6GZaCrdVnPLDZ1nmx+zevIZHbg7owpQ+twh91ZsTrCW2CyIlgiEphGo8d7DcHK/cLJP KExHk5hsRVeGJ2DztL75JwONH0iskicpXTIIk8v2raKM+RjHF16gL5S+z1ydQDKTSQt/O chnSTAg28NKRvv7KNlrYTv256rxLSGKUcyb2qwmuveVSsTcaQxr4D0YozbSqVOTlOBoLl kre+2gMkK7IRgHkaZ5B5gK5OLOE3gS875DMnug8yNTyrf0S7v4c36ApjwIKauJHelfvgU ZxCCG2k45Z/VwGasZMlMbE1yX2ekah1L8qif17YsbbIKw57WnLN51FqXo4gyyuJay+w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795772141; 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=hwQ67UPDDBpBlNdOHdQzfI33A0euocSSF71ObVKBPMQ=; b=pbFrFuNfJtdTcpyy80EaZ7KrtRNHKf2rEX5NkEC1p5ADsib1xxdtgl1GrXCy9mN8FhOB UEvytnDRYA9j58w9v6+BWzQg4QCEPD9uPeGfkJdLN8JzBNbAedQvPpL9ULj/CqkYCAOBd C5RXrSTPA3/MpBFbBZvvu5IBFVL9iEpA05RgUt3SNMKijDrFPvZsqEeiAwQmRBR6dB51B DLSNhIyApluigUazLElGq3KE6T1DblBzbF9s6h6qf7OFTsTf3f81eLYyML5NgqgYyLK9H nipmhFiQy64wde1d7F6nvOsfEk/k10FVE1wHPke5pW1KEkVlbsEpix6tzIAZ0dd9Rvw== 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=KT02Zom2; 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 53E9E606A321; Fri, 27 Nov 2026 09:35:41 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7C7B1F0089A; Fri, 27 Nov 2026 09:35:39 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795772140; bh=hwQ67UPDDBpBlNdOHdQzfI33A0euocSSF71ObVKBPMQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=KT02Zom2To/SSGxUt7pByiwxpkW4tayb6INs8CYUn3wwvvldjtiWAUtfnJbL4yr6E /YBg+LmKFBf36XYHDw99BG4wO2v+3fT1yBRsFjowboqCglXMD3Q6xOKIVDZTFJkgP6 Nuihh+rrD3OoUmS8lSF2lgtfhbVJNUUL/s45/8OO8tizYPYSPXJAHGXuYTP4wj+YRn i/mdnc6KT5PfzyiUODza2ZOuhJKhL8hJuY4HzIGqmffTI04E1XVRKrY8Q8LfUZ5u/U o3ahufR3CDlQe/03dgy5BiAnASU428/4Rtz6vjh8afPqWfu5K6ZF1bNhaKCDJYWTMx ErWGGqOjnGNWw== 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: <20261126092627.255454-1-guohongyu@cmss.chinamobile.com> X-sashiko-severity: High 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