๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8745

Re: [PATCH net-next v2] netdevsim: reject port addition and clean up ports after a failed reload

#8745
From: Hangbin Liu
Date: Fri, 30 Oct 2026 02:05
62 lines
10765 bytes
Hi, 
On Fri, Oct 30, 2026 at 03:13:20AM +0300, ร–mer Mete Kaya wrote:
> nsim_drv_port_add() does not check devlink_is_reload_failed(), so ports
> can be added via new_port after a failed reload.  nsim_dev_reload_destroy()
> returns early in that state, leaving them behind.  nsim_drv_remove() then
> hits WARN_ON in bpf_offload_dev_destroy() and a subsequent use-after-free.
> 
> Block port creation with -EIO when reload has failed, and delete any
> leftover ports on the early-return path as a safety net.
> 
> Fixes: 75ba029f3c07 ("netdevsim: implement proper devlink reload")
> Reported-by: syzbot+88435e204734072bf39a@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=88435e204734072bf39a
> Signed-off-by: ร–mer Mete Kaya <omermetekaya0@gmail.com>

Looks Joas has a same issue fix with yours a few hour earlier.

https://lore.kernel.org/netdev/179324296598.34505.11070163314749859668@gmail.com/

> ---
> Tested with syzbot C reproducer.
> v2: drop Cc:stable and target net-next.
> 
>  drivers/net/netdevsim/dev.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
> index feb88ccbbced..61f0824ce4d3 100644
> --- a/drivers/net/netdevsim/dev.c
> +++ b/drivers/net/netdevsim/dev.c
> @@ -1697,8 +1697,10 @@ 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)) {
> +		nsim_dev_port_del_all(nsim_dev);
>  		return;
> +	}
>  	debugfs_remove(nsim_dev->take_snapshot);
> 
>  	if (nsim_dev_get_vfs(nsim_dev)) {
> @@ -1758,7 +1760,9 @@ int nsim_drv_port_add(struct nsim_bus_dev *nsim_bus_dev, enum nsim_dev_port_type
>  	int err;
> 
>  	devl_lock(priv_to_devlink(nsim_dev));
> -	if (__nsim_dev_port_lookup(nsim_dev, type, port_index))
> +	if (devlink_is_reload_failed(priv_to_devlink(nsim_dev)))
> +		err = -EIO;
> +	else if (__nsim_dev_port_lookup(nsim_dev, type, port_index))
>  		err = -EEXIST;
>  	else
>  		err = __nsim_dev_port_add(nsim_dev, type, port_index, perm_addr);


But yours have an extra guard in nsim_drv_port_add...

Leave this to Jakub decide...

Thanks
Hangbin
Technical Details
Message-ID: <auP7VyY3MGqOphL-@bogon>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353535-linux-kernel-netdev=dewy.ru
References: <20261030001444.289973-1-omermetekaya0@gmail.com>

Show 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-353535-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2] netdevsim: reject port addition and clean up
 ports after a failed reload
Date: Fri, 30 Oct 2026 10:05:11 +0800
Organization: Usenet Network
Message-ID: <auP7VyY3MGqOphL-@bogon>
References: <20261030001444.289973-1-omermetekaya0@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2144562"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:afQOq+aQOe5S7vMde6AEpfdDJH8= sha256:YdoUAPizCMoHeXUWq1VInND8M6oPSi0zJKrRh8OVByY=
	sha1:wCzIGcXdVTLJFYc9tAl1qs1u3Vk= sha256:J8OjYTwx59k1VSNjQeBHSrHxBE8PBKOtN1kXmPkiAuI=
Content-Disposition: inline
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 55BF9125C7D; Fri, 30 Oct 2026 05:07:21 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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, 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 (1024-bit key)
	header.d=linux.dev
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 6oyuyu7aduiG;
	Fri, 30 Oct 2026 05:07:16 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353535-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 53B56125C77; Fri, 30 Oct 2026 05:07:08 +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 0FBCC2919A; Fri, 30 Oct 2026 02:05:43 +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=1793325942;
	b=AIvgLFzQS84z/DDbis2lHoAafQ8LiMBZoVsDQt38SrPSC2BE4CRexkn7hPkPYhG1wZ0m
	 te8UqpCOTigWGi8eVTN6ozsJ7D/SnBUz7N0HNrdIrfPoiW30TuEdQ6X1nTc5JMm57PJ1n
	 o0/3NHHwHGKV4x52JK084GFID0qIudbkfbWtmmuN8Q4fVYF1Mo5tFpEqwPMqFdXNFVT/w
	 EEgpBA6WlA76FwbF5TnrqGa53hkGmK+c8zEUUgW3WQ7vsXrb+Ff8kj2aSs3h4yJ9MkxDY
	 JqLUln7/z49ZIKDov7VCllBhe5+/t7p959LnHZrcxlM0sVVWhLXLXGNovMAq1XOPp1w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793325942;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:
	 Content-Transfer-Encoding:In-Reply-To;
	bh=5q6VLlVtRVGzt5myNjmdcIJTUsnVE4fKK2cK3gpYnOc=;
	b=BQ6VpAHRnLYyotFtlV0jJ8nAHJYBHro8ssN7C5/f4aLoaIp9gsEeu90QN7aYSRcSisVS
	 zvC06BWZa7N7sWp7P+BRf+CUKL/DnkYgVRCVoUjntwUiH753CaqeagYjYvF+bCnLXA1lB
	 sLYzShxEpT2BVO/qPNLvQ37xZpqwq971Z6IUrXYPaky1sof950ylRoui8EDh1eQE7ic3i
	 DJcQm8bClGZ5YnaqI9sIIATAZ7eYvPqlkNemljMF6WEbYzD3mGPntQEdRCW//zIC5N2gy
	 EAwf7ypT0KjJ/pCClWPmuUOjHxl3rskb3ZqY4HNvX7PWIPYH4zhjsroIwEN3woqGZ6A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=PfR+rHNA;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	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 D3138606A32C;
	Fri, 30 Oct 2026 02:05:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=PfR+rHNA
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.148
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793325942;
	b=PpnBXP5q8NyHYwn++Ck/yHA+TDcV9iOA4oxPRgGYqYRqiwiLze2ynUVU5BURsUM/J/cW
	 9Tdx/00tydzCpSPnnbrLlWsecV+J3utkyf8irNB/IYMMoe3a/ADUalovO5S4NxosSuoBJ
	 4VyL/qtVsbLMEBc7AMwCXvOGFGJV6sJqCaRKLrgrTrMR7BmuNyH9HK7d0SM7oclvDRtZz
	 B1IIwG8umWYtZo+/82BHLxHWnsqAzeVy9RCdWjdvNvcO4TohtyVJRQ7w8nhq3eZ8qKzRv
	 h+1igkOwjOo5pkSyDwPInKk9OfpM2Pp96t0QJzcIrwWPjVXVP96+8jBsKstkWxFo7IQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793325942;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:
	 Content-Transfer-Encoding:In-Reply-To;
	bh=5q6VLlVtRVGzt5myNjmdcIJTUsnVE4fKK2cK3gpYnOc=;
	b=e6eV+IFjuId+FsvKXutU0P84+PCZjtyTy7uynF+4ziREYml70ZEhucRrmjorLNSTq7Av
	 WfRcpxiqTFKzOZ3vfY0dNm6U2YeSMDHftFv3MrFf7pDyQdumkvVPkfWOi1kBR1kPdKHIL
	 qat2E81WL5s9uvvre9JDPFZ+HmRy4/gFMGFrX7EVsJBB3CqAopKzHzcGIRfFOV7hlXQfA
	 2CzvJOlprg3Vi9Gyb8zPPWbKQP9M03Y+7NY0buEicl2crtj3IwG0jhWO/NWXUYoIQ0nRR
	 MfG1gjlvxmxjapkF1GKM0H+NzGgs1fnCbqxODZ/93Nhu/YPC62eyfqUGtOfJTIEsl1g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=PfR+rHNA;
	arc=none smtp.remote-ip=91.218.175.148
X-Received: from mta0.migadu.com (out-148.mta0.migadu.com [91.218.175.148])
	(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 0E2E3606A31A
	for <netdev@vger.kernel.org>; Fri, 30 Oct 2026 02:05:40 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0E2E3606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=9cmqbsbAYRunmp/btWpjdtkpFl2yYOXgBmGWd0cWFJQ=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1793325939; v=1; x=1793930739;
 b=PfR+rHNAuyMeSUsq8dt1qw+B7dfBtmt1xW7FyBiIgPtM9FobTgY+6F4rSz2u82NdCzpSDYN0
 tXdxT/MUDaEizK+nZ/90aQqcFP2uIW5D1NVcveUqsmmgMsJcX9eFstVx28Pjzx41kAZXKxL0nKR
 8V7INOUFfUFudUcYKCXTUT9I=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta10.migadu.com with ESMTPS id 62c2abc1fac3e23c;
	Fri, 30 Oct 2026 02:05:22 +0000
X-Mizu-Trace-ID: 62c2abc1fac3e23c
X-Migadu-Flow: FLOW_OUT
X-Cc: Jakub Kicinski <kuba@kernel.org>, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Joas Antonio dos Santos <joasantonio108@gmail.com>,
	Eric Dumazet <edumazet@google.com>, Paolo Abeni <pabeni@redhat.com>,
	Jiri Pirko <jiri@resnulli.us>,
	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
X-In-Reply-To: <20261030001444.289973-1-omermetekaya0@gmail.com>