Re: [PATCH net v7 2/4] ice: do not leave switchdev mode while subfunction ports exist
From: Ivan Vecera
Date: Thu Dec 03 2026 - 05:56:46 EST
On 12/2/26 08:16, Petr Oros wrote:
ice_eswitch_mode_set() refuses a mode change only while VFs exist, but aReviewed-by: Ivan Vecera <ivecera@xxxxxxxxxx>
subfunction port has a representor and a switchdev session too. devlink
core usually refuses the change first, because of the devlink rate nodes
the representors export, but ice exports none while DCB is active. A
switch to legacy then destroys the representor xarray under the running
session and the uplink stays in its switchdev configuration. Deleting
the SF port afterwards frees its devlink port while it stays
registered, so a later devlink port dump reads freed memory.
Refuse the switch to legacy while subfunction ports exist. Check
pf->dyn_ports, which only changes under the devlink instance lock held
here, while ice_sf_dev_probe() can change the representor xarray
without it.
Found by AI code review. Reproduced on an E810-C (FW 8.1.1, ICE COMMS
package 1.3.55.0) with the firmware LLDP agent off, without kernel
changes:
dcb ets set dev $PF tc-tsa all:ets tc-bw 0:50 1:50 prio-tc 1:1
devlink dev eswitch set pci/$BDF mode switchdev
devlink port add pci/$BDF flavour pcisf pfnum 0 sfnum 88
devlink dev eswitch set pci/$BDF mode legacy
The last command succeeded, the representor netdev stayed registered
and promisc off no longer took effect on the PF. Deleting the SF
port then returned 0 and the next devlink port list read its freed
devlink port, KASAN reported a slab use after free in
devlink_nl_port_fill(). With this patch the mode switch fails with
"Remove all subfunction ports before changing eswitch mode", after
the SF port is deleted it succeeds, and promisc off takes effect
again. No kernel selftests cover this.
Fixes: 977514fb0fa8 ("ice: create port representor for SF")
Signed-off-by: Petr Oros <poros@xxxxxxxxxx>