Article View: linux.kernel.netdev
Article #8445[PATCH net] netdevsim: delete ports added after a failed reload
From: Joas Antonio dos Santos
Date: Thu, 29 Oct 2026 03:02
Date: Thu, 29 Oct 2026 03:02
80 lines
14302 bytes
14302 bytes
When a devlink reload fails, nsim_dev_reload_down() has already torn
the device down through nsim_dev_reload_destroy(), and
nsim_dev_reload_destroy() returns early on every later call because
devlink_is_reload_failed() is set. new_port still works in that state
though: nsim_drv_port_add() does not look at the reload state and adds
the port to nsim_dev->port_list. Nothing ever deletes it. When the
device is removed, nsim_drv_remove() destroys the BPF offload device
and frees the devlink instance while the port's netdev is still
registered:
WARNING: kernel/bpf/offload.c:794 at bpf_offload_dev_destroy+0x50/0x78
nsim_bpf_dev_exit+0x7c/0xbc
WARNING: net/devlink/core.c:557 at devlink_free+0x30c/0x3ec
and the leftover netdev then points to freed memory. Bringing it up
afterwards:
BUG: KASAN: slab-use-after-free in devlink_bus_name+0xa0/0xac
Read of size 8 at addr fff000001a313118 by task ip/120
devlink_bus_name+0xa0/0xac
devlink_nl_port_handle_size+0x38/0x80
if_nlmsg_size+0x340/0x7a8
rtmsg_ifinfo_build_skb+0x74/0x218
rtmsg_ifinfo+0xa0/0x18c
__dev_notify_flags+0x1d8/0x2f4
netif_change_flags+0xe0/0x150
dev_change_flags+0x8c/0x1e4
devinet_ioctl+0x9c0/0x1360
A successful reload after the failed one has the same problem:
nsim_dev_reload_destroy() skips the ports again and
nsim_dev_reload_create() then reinitializes port_list over them.
The ports are the only thing that can be created after the failed
reload, so delete them on the early-return path too. The port_list is
valid there: the failed reload emptied it with nsim_dev_port_del_all()
and nsim_dev_reload_up() fails before nsim_dev_reload_create().
Fixes: 75ba029f3c07 ("netdevsim: implement proper devlink reload")
Reported-by: syzbot+88435e204734072bf39a@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=88435e204734072bf39a
Cc: stable@vger.kernel.org
Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
Assisted-by: Yaga Agent HackerSec Claude:claude-opus-5-5
---
Tested on net/main 94cea342e891 (arm64, QEMU, generic KASAN) with the
syzbot C reproducer (sets fail_reload, does a devlink reload, adds a
port with new_port, then del_device), followed by "ip link set <dev>
up" on any netdev left behind. Without this patch both WARNINGs above
fire, the port's netdev survives del_device, and bringing it up gives
the KASAN report above (2 of 2 boots). With it, 3 of 3 boots show no
WARNING or KASAN report and no netdev is left behind.
drivers/net/netdevsim/dev.o builds cleanly with W=1. The
reload-after-failed-reload case was not tested separately.
drivers/net/netdevsim/dev.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index feb88cc..a871790 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -1697,8 +1697,13 @@ static void nsim_dev_reload_destroy(struct nsim_dev *nsim_dev)
{
struct devlink *devlink = priv_to_devlink(nsim_dev);
- if (devlink_is_reload_failed(devlink))
+ if (devlink_is_reload_failed(devlink)) {
+ /* The failed reload already tore everything down, but ports
+ * can still be added through new_port after that.
+ */
+ nsim_dev_port_del_all(nsim_dev);
return;
+ }
debugfs_remove(nsim_dev->take_snapshot);
if (nsim_dev_get_vfs(nsim_dev)) {
--
2.39.5
Technical Details
Message-ID:
<179324296598.34505.11070163314749859668@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353141-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353141-linux-kernel-netdev=dewy.ru
From: joasantonio108@gmail.com (Joas Antonio dos Santos)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] netdevsim: delete ports added after a failed reload
Date: Thu, 29 Oct 2026 00:02:45 -0300
Organization: Usenet Network
Message-ID: <179324296598.34505.11070163314749859668@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1923272"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:QeAIIwuomyhFzy7/XSiPWTy3RRQ= sha256:mbE+xF+jtncaXldORIR86dBxK+XaLPNh7taTICQyTPg=
sha1:PpGjgq47Jr5lTsPVAxYeKwQcil8= sha256:+gY8fFNiObMaR25739XXrZZ0StSOLKum+2u4+7kWsrU=
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 C06C6125C51; Thu, 29 Oct 2026 06:03:20 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.047
X-Spam-Status: No, score=-3.047 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
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=gmail.com
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 4I_LhAWRWfqV;
Thu, 29 Oct 2026 06:03:17 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-353141-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id 4C825125C44; Thu, 29 Oct 2026 06:03:06 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sin.lore.kernel.org (Postfix) with ESMTP id DB9A824E51; Thu, 29 Oct 2026 03:03:00 +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=1793242977;
b=YSB3QsdH+PJ1nlk3oODJgyX/M/J2I72AJX3v0djvX7cfR8MnEhtkZ24xyKPar2XM1yID
MbHsX73n/rvP+HzpNPcT9SXxoLVsWs3hGLJBO1aT8dz6T4H2usYrjInxrnABv2G8s9/ty
osNTpegr4fLzN3Y+Xn1EcrDJ30qHNasEHy4by60rC+/xH7XOc7qbW5uGwPpxysyxXpOlY
FnfAos2UT9Pk2+foaPwgpZ+GMhoYl03fVc2K8gsm080T9ZRFKI/X/r88tUujoOdJ4ljpD
1kZ/hOFM7qafAwL+75DZAFR5AnjTty+RX2x7pmEHF8OutOAkQdbP4fNyJbyp1tieY2A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793242977;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version;
bh=MJTAFr/nct8BR2PWhY9m1x54UXhrbFHiuq7wCiirHbA=;
b=aaPSNYKycy64qSxzuUD5YEJemeM2obCgay4n8x4JMHV3jzINijnlQFILKYsGle+332so
PYczxiJdfuh7+x+DChKYmrNp5Po6KXSPaTWmHUMjdq34spBfjJTXoH+cdxDxtaBQRBaZG
1EPUnz5j8nVyQ3974QcKsu6OrtgREmB71/nr9ZPDxZNkxnbk/iGG7u7vVNHo8+yeqSnmm
COBeHoFgi36AmoD36JCnprQnF5Firvg3vICMiRtuovGTGLSxEXsa67sAMNnAkqjwuB8UH
XiybST96siZL3alrAJ2DCi9aomJ1uy+0LQc1APSGZOH7tW6VBeaUCjd2Pz++Ddm2wTQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=i20N95rk;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
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 A8184606A329;
Thu, 29 Oct 2026 03:02:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=i20N95rk
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.217.46
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793242976;
b=sS8aaVNlw8j2R1xWNZk6nPinY5lEHDS2Bf8PrvnWVH+9nI6jv8Enu1Up+/D8moMfUeuk
FHk9nrIgRC7K857FyZaM4Tf/zAdEH6h8h2OnM+yJB66rHafGGXInxwFyqpgs/QpN3L3Kv
Gt2G2i+CWX2Ay7e7/1ZZJYhzUpdUSOLORTYeNb2quCf4A0odsT0Pit5Z9MgTYOsEpM6Vr
j+y1CPw+ZBm9Km7bj43R0TCaB1PEFX68hkgyTrnHeqwezvWx3A+nZs4uVGeayOOsr/DzT
93pD1JwToLO0sPHVZv8DuGyMKQVYnMTMTEhAuf8vOCEnEQYPQzCNhROaD3O3mHTnGpg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793242976;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-ID:Content-Type:
Content-Transfer-Encoding:MIME-Version;
bh=MJTAFr/nct8BR2PWhY9m1x54UXhrbFHiuq7wCiirHbA=;
b=ElRYSQKcy8Pa+akV85D6AAfZOYNZB9uaXIGGtA8cHlEOkd5946Ma4UrdKE2YaSg/KKw2
Fn8vFCVnIk7e24kj0WVTSC5QQycZzOiBr+GuuTDnuH32eNEbIjwKXXar/3YM4jwYtbI+q
bPbyWENWHeyBflYCBbMoVNU8ywI7qzrIlLtbvmtzTyE7QjDZL+MMai1JoykDuMinw65Lv
CnUlm+CM46c/ktSPvwjhKgE9tVGIp4Uh5XS+jCjp3yN57SO0AM7mpGyGO+hfwEPeueZnW
6JYMVLANnVOX8dX7lWc1162ftF4hRCkvZjKG48EGXu1ezFbAuiKW2GsZTyXOpuy5DCA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=i20N95rk;
arc=none smtp.remote-ip=209.85.217.46
X-Received: from mail-vs1-f46.google.com (mail-vs1-f46.google.com [209.85.217.46])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75AA1606A31A
for <netdev@vger.kernel.org>; Thu, 29 Oct 2026 03:02:56 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 75AA1606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-vs1-f46.google.com with SMTP id ada2fe7eead31-7cc365db987so983394137.0
for <netdev@vger.kernel.org>; Wed, 28 Oct 2026 20:02:56 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1793242975; x=1793847775; darn=vger.kernel.org;
h=mime-version:content-transfer-encoding:content-type:message-id:date
:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=MJTAFr/nct8BR2PWhY9m1x54UXhrbFHiuq7wCiirHbA=;
b=i20N95rk6wxtdrQR+q3G5uzJPMIU4uWjvFTaKwCl1gislcnxgJsFidAdjdmOLPl110
49XDz9Ofu4cv/FmlQuzhOaMZWTxecTZMCl72NhkqzWL9N/fDjJ0uph1JjPH67cGWNEoE
ZKi+NDn23oEmvVHdLsKjaLAugggQI5mom5ZLq9mnMXgSws7QSRc8TnJdp2HmrDxHh//B
yERDj32KXG5VzjcmEVH8sGlpQLdginhb/P+D8Nsfp0SkM0XvBOKiYQR9FHGmB/6nv9VZ
KwEX9uW+MxZZmuXrxsVunrcLeXFXccx5uKysi8hwpBxS8lHE5KDALxN7JMkKO/2rZzLr
EeRA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793242975; x=1793847775;
h=mime-version:content-transfer-encoding:content-type:message-id:date
:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=MJTAFr/nct8BR2PWhY9m1x54UXhrbFHiuq7wCiirHbA=;
b=tzb9OQOmGuCu9d1qUs+SK++ex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t3B6QwL3fCFLDXcuE4KOOy6iEC8
XMldhmG3004j5U4ZSqPZlCHDHPm2TMMxXiU2goEJhzidYCAzbx6uUNt0bMYdWsTiSJ+XuKIB/+o
mPwPQPUashfGl3ZrS8FYljcVRLhzjlrWan1hpZ7sAGOi3Ap/9tX52BUGrzPHxHSg7OsQy0szGCB
HE56wZtdJZQqYvkLAZFY/Kpw+RQPX
X-Received: by 2002:a05:6102:2906:b0:7cc:16e2:c1a8 with SMTP id ada2fe7eead31-7d03a4ba6femr2067670137.8.1793242975276;
Wed, 28 Oct 2026 20:02:55 -0700 (PDT)
X-Received: from macbook-pro-de-joas.local ([2804:7f0:b101:c5e8:7d75:cb37:7054:6d4b])
by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5ec4f931911sm3939350e0c.10.2026.10.28.20.02.47
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 28 Oct 2026 20:02:54 -0700 (PDT)
X-Cc: Andrew Lunn <andrew+netdev@lunn.ch>, David S. Miller <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
syzbot+88435e204734072bf39a@syzkaller.appspotmail.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
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