Re: [PATCH net] netdevsim: fix panic when NETIF_F_LOOPBACK is set on a VF port
From: Jakub Kicinski
Date: Mon Aug 31 2026 - 23:16:51 EST
On Mon, 31 Aug 2026 12:22:20 +0800 Jiayuan Chen wrote:
> A netdevsim VF port cannot process incoming data. It never runs
> nsim_queue_init(), so ns->rq is NULL, and nsim_vf_netdev_ops has no
> ->ndo_open, so its NAPI is never set up either.
>
> Since commit 358008f41d9b ("netdevsim: add loopback support") an outgoing
> netdevsim can also be the incoming device. nsim_setup() is shared by PF
> and VF ports and offers NETIF_F_LOOPBACK to both, so the feature can be
> turned on for a VF; nsim_start_xmit() then takes ns as peer_ns and
> dereferences peer_ns->rq[], which panics.
None of the offloads are there either, hm.. VF already has its own
net_device_ops struct. Let's replace:
.ndo_start_xmit = nsim_start_xmit,
with some dedicated nsim_start_xmit_vf() which unconditionally
drops the traffic? Even if we clear the LOOPBACK it will be easy
to re-introduce the bug by adding some PF-only code in the PF xmit.
--
pw-bot: cr