Article View: linux.kernel.netdev
Article #23824Re: [PATCH net v5 2/4] ice: do not leave switchdev mode while representors exist
From: netdev-bot+sashiko
Date: Sat, 28 Nov 2026 09:30
Date: Sat, 28 Nov 2026 09:30
194 lines
15689 bytes
15689 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 3
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] The new `xa_empty(&pf->eswitch.reprs)` check in
ice_eswitch_mode_set() is protected only by the PF devlink lock, which…
- [Low] The commit message understates what this patch fixes.
- [Low] In ice_eswitch_mode_set(), the new
`!xa_empty(&pf->eswitch.reprs)` check (ice_eswitch.c:358) runs before…
- [Low] The new gate checks whether pf->eswitch.reprs is empty, not
whether SF ports exist.
--
ice: do not leave switchdev mode while representors exist
This patch makes ice_eswitch_mode_set() refuse an eswitch mode change
while the representor xarray is not empty. Before the patch, switching to
legacy mode with DCB active could destroy the xarray under a running
switchdev session that still had a subfunction port representor.
> the representors export, but ice exports none while DCB is active. A
> switch to legacy then destroys the representor xarray under the running
> session, the representors leak, and the uplink stays in its switchdev
> configuration.
[Severity: Low]
Does "the representors leak" describe the whole consequence? Before this
patch, the later SF port deletion looks like it ends in a use-after-free
of dyn_port.
Once the switch to legacy has run xa_destroy(&pf->eswitch.reprs), a
devlink port del on the SF port goes through
ice_devlink_port_del()->ice_dealloc_dynamic_port(), which calls:
drivers/net/ethernet/intel/ice/ice_eswitch.c:ice_eswitch_detach_sf() {
struct ice_repr *repr = xa_load(&pf->eswitch.reprs, sf->repr_id);
if (!repr)
return;
...
}
So ice_repr_rem_sf() never runs. That means neither
unregister_netdev(repr->netdev) nor
ice_devlink_destroy_sf_port()->devl_port_unregister() is called.
ice_dealloc_dynamic_port() then does:
ice_eswitch_detach_sf(pf, dyn_port);
xa_erase(&pf->dyn_ports, dyn_port->vsi->idx);
ice_vsi_free(dyn_port->vsi);
kfree(dyn_port);
The embedded dyn_port->devlink_port is still registered in devlink->ports.
The representor netdev is also still registered, and it keeps pointers
into the freed dyn_port: repr->sf, and the devlink port set through
SET_NETDEV_DEVLINK_PORT(). Driver removal takes the same path through
ice_remove()->ice_dealloc_all_dynamic_ports().
The code change closes this path. Could the commit message mention the
use-after-free, so stable and CVE triage can weigh the fix correctly?
> diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
> index 6e7bba4738989..c96b201901f48 100644
> --- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
> +++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
> @@ -354,6 +354,13 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,
> return -EOPNOTSUPP;
> }
>
> + /* subfunction ports have representors too */
> + if (!xa_empty(&pf->eswitch.reprs)) {
[Severity: Medium]
Is the result of xa_empty(&pf->eswitch.reprs) stable under the lock held
here? devlink core holds only the PF devlink lock around
ice_eswitch_mode_set(). However, ice_eswitch_update_repr() changes the
same xarray from ice_sf_dev_probe(), and that path holds only the SF's
own devlink lock:
drivers/net/ethernet/intel/ice/ice_sf_eth.c:ice_sf_dev_probe() {
...
devlink = priv_to_devlink(priv);
devl_lock(devlink);
err = ice_vsi_cfg(vsi);
...
ice_eswitch_update_repr(&dyn_port->repr_id, vsi);
...
}
drivers/net/ethernet/intel/ice/ice_eswitch.c:ice_eswitch_update_repr() {
...
if (repr->id != vsi->vsi_num) {
xa_erase(&pf->eswitch.reprs, repr->id);
repr->id = vsi->vsi_num;
if (xa_insert(&pf->eswitch.reprs, repr->id, repr, GFP_KERNEL))
...
}
ice_sf_dev_remove() does not delete the hardware VSI. So if the ice.sf.N
auxiliary device is unbound and then rebound through sysfs, ice_vsi_cfg()
runs with ICE_VSI_FLAG_INIT and allocates a new VSI number. That takes
the erase/insert branch above.
With a single SF representor and no VFs, can a concurrent eswitch mode
change see the xarray empty between the erase and the insert?
CPU1 (SF rebind, SF devlink lock only)
ice_eswitch_update_repr()
xa_erase(&pf->eswitch.reprs, old_id);
CPU2 (PF devlink lock held)
ice_eswitch_mode_set(LEGACY)
!xa_empty(&pf->eswitch.reprs) is false, check passes
xa_destroy(&pf->eswitch.reprs);
pf->eswitch_mode = mode;
CPU1
xa_insert(&pf->eswitch.reprs, new_id, repr, GFP_KERNEL);
The result is legacy mode with a live SF representor, and
pf->eswitch.is_running stays true because ice_eswitch_disable_switchdev()
is never called. The uplink keeps its switchdev configuration until the
SF port is deleted. This same check then refuses a switch back to
switchdev.
Would checking pf->dyn_ports instead close this? Its writers,
ice_alloc_dynamic_port() and ice_dealloc_dynamic_port(), run under the PF
devlink lock, so they would be serialized with mode_set.
[Severity: Low]
A related case: if that xa_insert() fails, ice_eswitch_update_repr() only
logs an error:
if (xa_insert(&pf->eswitch.reprs, repr->id, repr, GFP_KERNEL))
dev_err(ice_pf_to_dev(pf), "Failed to reload port representor %d",
repr->id);
If that was the only SF representor, pf->eswitch.reprs is now empty. The
SF devlink port is still in pf->dyn_ports, and pf->eswitch.is_running is
still true.
Would ice_eswitch_mode_set(LEGACY) then pass both ice_has_vfs() and the
new xa_empty() check? If so, it would run xa_destroy() and switch to
legacy without calling ice_eswitch_disable_switchdev(), leaving the same
orphaned session this patch is meant to prevent.
The dropped-entry handling in ice_eswitch_update_repr() predates this
patch, but a check on pf->dyn_ports would also cover this case.
> + NL_SET_ERR_MSG_MOD(extack,
> + "Remove all subfunction ports before changing eswitch mode");
> + return -EOPNOTSUPP;
> + }
> +
> switch (mode) {
[Severity: Low]
Should the requested mode be validated before the representor check? The
devlink policy accepts DEVLINK_ATTR_ESWITCH_MODE values up to 2
(NLA_POLICY_MAX(NLA_U16, 2) in net/devlink/netlink_gen.c). So
DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE reaches the driver, and ice
rejects it only in the default branch:
default:
NL_SET_ERR_MSG_MOD(extack, "Unknown eswitch mode");
return -EINVAL;
With the PF in switchdev mode and an SF port present, a switchdev_inactive
request now fails with -EOPNOTSUPP and "Remove all subfunction ports
before changing eswitch mode". If the SF ports are removed as the message
says, the retry still fails, this time with -EINVAL.
The existing ice_has_vfs() check has the same ordering, but this patch
adds a new path that reports the wrong reason. Would it be better to
validate the mode first, or to apply the representor check only to
supported transitions?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127085714.1207361-1-poros%40redhat.com
Technical Details
Message-ID:
<179585820824.3135.14448452752875011743@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373071-linux-kernel-netdev=dewy.ruReferences:
<20261127085714.1207361-3-poros@redhat.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373071-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v5 2/4] ice: do not leave switchdev mode while representors exist Date: Sat, 28 Nov 2026 09:30:08 +0000 Organization: Usenet Network Message-ID: <179585820824.3135.14448452752875011743@kernel.org> References: <20261127085714.1207361-3-poros@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="922087"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:VExPc2pOO1AbS4GdYnGRqZJwdjM= sha256:PgEMCZdSN8G1q3oUUUSZ3ebGb+hqkQ3Srkn4gBYkamU= sha1:oLjyvlLdDZiY6ytZQnYnKBEAxtI= sha256:DV8Ht+nKwR3J60lTmIZ/ycRF6xprFSwt36uozoSowhg= 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 EB2E9125F77; Sat, 28 Nov 2026 12:30:29 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.5 X-Spam-Status: No, score=-3.5 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, URIBL_BLOCKED=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 fa-otEqfZmzJ; Sat, 28 Nov 2026 12:30:25 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-373071-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 7F240125F70; Sat, 28 Nov 2026 12:30:16 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 0E49D28A61; Sat, 28 Nov 2026 09:30:14 +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=1795858211; b=ziX8r/GhQ7pDIG5Ft1/JjiZDmKGoMFj6nn1+dWS4NSycEeE5qQg0pDEe+cS38Sl0A9tM yFRxZ1HWqrSpS21XuN5/F70zHGFB8WAc+UHXixBxX9CPJzq05HSdOuwo7rAOGy9pcZ3Js SxmC5+Vg5RJpo3yhVRDlKXEm0LtvwoGAjhkxDnUfyuH0IQ28dlA2igQZJIe0uEiYKPeVP KjTnuDJwE71YgAmOY0D9993Ytlg3aMEUrXAm7L3qjwYHM9vU3w05JGGs+Oq6i9R+yv0BR 96ynFuTE9JQV3qAMtBfoXZt59H30i0RjMo8LIjSVQxBuSBwXUseedkXlefAcMqYr4BQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795858211; 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=A5rYtmofrvIUFyhmWGcR3PlpZPgkJO+PijhIDMldm2Y=; b=hnb7kJJy8qkyofpd8vmmqgM7O5c29HbjCX9iP361RFpVPuvk4SQA4lgtpYNVRI0HZEKs bNO6vXAeWtCk9nLXt5pAq552vXmrSIKj0tM2glubat4KCIC0i8ibnXoknrmx9Fn54Q53V Y8XpbAN0WeI4VvyYCRHh1Dt2MDRr9/3bkZon0otjQjuOGINpmmn4LdBoCUrA2jZT5AJuE hBWkWwTzlSmu2V2GForPYos7CXXoQWmYBuQDre8zHZw02GyLrk1qOXjhEWvBTLgeel87Z JTwPsbb1lrKi1X04ZQkVej3ARtv3Ovs4MK6eqEsW7Gs7i3cDBoSUsWfK8ecG1oG9I1w== 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=dHvm+u5R; 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 6EE47606A32E; Sat, 28 Nov 2026 09:30:11 +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=dHvm+u5R 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=1795858210; b=xSnOJb1xjRCC6+ri/jjHKpw/D0WsKzeddQYCM15xQQlgg1G1fVepFAQFLjuJ3sQH59UI YLDD6X3Tg+0fOowHil/nlMf5BLzvWOmV6IxhggyypcFW/IGZNuu1iZa2vVXoQb+roaNWL jTP8OElT14/bYvVj4j+0PsWYSlSsI2c2pIMCOYFgJVEFg66z/JakDS82f6XFKt+7sK1O3 iiCbhppD491xsiMLhH17HLF81uv0ioXE+hwJYb1s9VrciX6GpwbF19E1dXgfDMxToQ2EH DOJh2Nt3axsmifoyN0YEwQItKS3PyQBkTqTSzbPEA3BmsKlTdpI9ym50axes9EzcMNQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795858210; 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=A5rYtmofrvIUFyhmWGcR3PlpZPgkJO+PijhIDMldm2Y=; b=CQ2fFfQdrd6UMnWENCbsW2MT01Li/P/3fvo6Bo71P2/l3bakThw+9kUBiXTOlvXlU0qN avQGm65gNFw1uCUbE/1OfwM6TPMjYlOaodZF7RDD0fbK5L3XxsDRBbqW+SN+ZXlnxQ9tl p7qBoYrM168l+kYotW/Lw1OwYxU89ZswB88xyISQc/gmK+ToTJEvmznyvUYrME1rKlQqr 51o9md/lXQPOJI3GyvjBSk6f2BsqVLBeHrZn3xJY28UjmusDGndXvGREvVbF/+JiPL3n1 1Q7iYxYHSTv/8BwmAzQ2IUVCJoOi8CpzUb8EbFGUaJKgZJ/gFGglVILm8OmgNb+VYtw== 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=dHvm+u5R; 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 8BBC6606A324; Sat, 28 Nov 2026 09:30:10 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A34981F00898; Sat, 28 Nov 2026 09:30:08 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795858209; bh=A5rYtmofrvIUFyhmWGcR3PlpZPgkJO+PijhIDMldm2Y=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=dHvm+u5RvRSNSfxYyIJNDgl1oVQS4z17YRrU6ZdKkhUMLZGtcJVJFMSH69avJWPiA 7mYaddu5flKEAvjr+oya3/xIEXlPpEDLAfbqojDD7ar0J+ceZh0KVuDzJQSimwseXz rEjq421poQEOaychfqxvmkhkri1jVsvqegU3t8uPQI1KfqafvI411fNNHQhUAGRBMb Fs+SNNl3jgjtiH2cnCjYWayZs9O5FXOBtTeX2A7HsDKGBtEoJAYOwARBSZhdHfz6wy wdzXvnQDtaJyFZLSDTL3Y1CwzObeRYdE6z8u1KqKGoLBlRq440Pm2THHzShpREzFTx d5xZD52m2LhwA== X-Cc: 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, aleksandr.loktionov@intel.com, horms@kernel.org, michal.swiatkowski@linux.intel.com, grzegorz.nitka@intel.com, pmenzel@molgen.mpg.de, wojciech.drewek@intel.com, marcin.szycik@linux.intel.com, martyna.szapar-mudlaw@linux.intel.com, ivecera@redhat.com, alice.michael@intel.com, jacob.e.keller@intel.com, jbrandeb@kernel.org, patryk.holda@intel.com, sx.rinitha@intel.com, aaron.ma@canonical.com, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261127085714.1207361-3-poros@redhat.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