🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8052

Re: [PATCH net] devlink: region: fix snapshot id leak on kernel-allocated ids

#8052
From: Jakub Kicinski
Date: Tue, 27 Oct 2026 22:47
25 lines
8857 bytes
On Mon, 26 Oct 2026 18:44:03 +0100 Fernando Fernandez Mancera wrote:
> When DEVLINK_CMD_REGION_NEW is issued without a snapshot id, the kernel
> allocates one with __devlink_region_snapshot_id_get(). That helper counts
> the caller as a user of the id, and the caller must release this hold
> once it is done.
> 
> devlink_nl_region_new_doit() never drops it. The refcount of the id goes
> 1 (allocation) -> 2 (snapshot created) and stays at 2. When the snapshot
> is deleted the count only drops to 1, so the id is never erased from
> the snapshot_ids xarray. The id then stays in use for the lifetime of
> the devlink instance: requesting a snapshot with that explicit id fails
> with -EEXIST, and there is no snapshot left to delete to clean it up.
> 
> Reproducer steps:
>   # devlink region new pci/0000:13:00.0/device-caps
>   pci/0000:13:00.0/device-caps: snapshot 0
>   # devlink region del pci/0000:13:00.0/device-caps snapshot 0
>   # devlink region new pci/0000:13:00.0/device-caps snapshot 0
>   kernel answers: File exists
> 
> Drop the caller's reference right after the snapshot has been created,
> as the snapshot then holds its own.

bit of an odd reference counting flow in this code but okay..
Technical Details
Message-ID: <20261027154708.5138e1af@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352645-linux-kernel-netdev=dewy.ru
References: <20261026174403.512-1-fmancera@suse.de>

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-352645-linux-kernel-netdev=dewy.ru
From: kuba@kernel.org (Jakub Kicinski)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] devlink: region: fix snapshot id leak on
 kernel-allocated ids
Date: Tue, 27 Oct 2026 15:47:08 -0700
Organization: Usenet Network
Message-ID: <20261027154708.5138e1af@kernel.org>
References: <20261026174403.512-1-fmancera@suse.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="1650882"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:TITcoKLc+x9xZOEy/qaGYC5S1YI= sha256:3dDhakWRahRtbwZfK7qMYx/A3Kh5fP80GVm9Krs1O8o=
	sha1:mb4dw4nxlLkpk5r5G07fs7M8m1c= sha256:mfwzEs4I4K1iMXCOKnT/FdtgZYo7twkoWz5WiY2rRiM=
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 25B80125C29; Wed, 28 Oct 2026 01:50:36 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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] 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 1b5KtlEMr39W;
	Wed, 28 Oct 2026 01:50:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-352645-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 27B9E125C25; Wed, 28 Oct 2026 01:50:23 +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 8C0892CABB; Tue, 27 Oct 2026 22:47:10 +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=1793141230;
	b=QRIx7wbYrbD0K2jBrpI+4+QCFO1b5E7y+wY24b/YzUMEkJgZWKsaNaET66RxdFHD/kKs
	 XlUbfTd0kh46/VpFuFFr+9ZJz5SYjLsP6NuPzNSbnUOc2XEj9aUG7QO3Vrm+5Frpk30kI
	 0miLZ9xWiwkK+78SqV+2w8xwRgPpXZgmdckqGVH7kYl2K62JG72C710DFbCXhWnq98UKl
	 2J3dz5ECEYX8E8bioWRWUeCvbcIGWncP8SpYF+BpeHOYwzj6SpUKsPO3ehZ4/gZf5+JkM
	 dVXSRrxoG4qxtVol+kepEfNP9oCCv3BhVQ8qqLSjBUsCW9R8p8q9CSDbTeT1E4amiow==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793141230;
	h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc:
	 Subject:Message-ID:In-Reply-To:References:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding;
	bh=BRhWps6yiPo6vqGKqMu5wMjShEbWK2OtLM+mwipcvo0=;
	b=WliEQt3EyLVdx0QZrWC27ynkozqAEu3gfX7yduKoP8HNfq1L0FvOwmoz8yYbKNEiZupg
	 x21AZI3CyjjThYLegJAK/Fg7wS3sg2pXg647ue9Gn5EQQmcCaxVr7VmLpoXvByUFwIibd
	 PVM0DbPh7Cjs8jV2Ru2epcQmfb0LhDRfqEFZOU0LPBlxeZ5q2P9U8sqkyY04dv7wAXMJQ
	 iP2/5qBa2/+g1EKV+4kplotiSs3Y78ucFZTj22QVyQF7Yw9i0k3ASbQWhJ1Q2UrrocTA0
	 pu7320lLqiKyxm8whcSrCL+JmM44v2Nrzda+EyiYmtG7GG5kZWSds6Q0N8znp/fyLjQ==
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=inJSfAYG;
	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 5FAE2606A322;
	Tue, 27 Oct 2026 22:47:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=inJSfAYG
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=1793141229;
	b=H04rrX2ilPHU5bXkFrhf7MlI1dUPAeNJkUSNZitJ1lW/7+/TqEK4L6jQt1jhdKEBmFig
	 vKzNTdK4OXoxjLm3WIKZ5mwxN/QsbjuRJuEXnmfbbpM1q+lGEmlquAXkxTa9VuR34JRwc
	 3rV8XLexHlvtxpuRCeUwQzE3y1F36cM5snG7biuXfAAcjtU3DoU/lO+K9K8QfmwFYHebt
	 MXgeQ13p+thTK5MYxNy9xhN5i7ueGzGWtaNeUlaWiGvo5FxnuMV//cSD4Vq+opaa67xea
	 6vRqc53rLGCbGhtE8AjJDD56yN9Jyt0POQuU+/YzM6V96FpcDhvOYi/fXRnw8ZvvzvQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793141229;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 In-Reply-To:References:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=BRhWps6yiPo6vqGKqMu5wMjShEbWK2OtLM+mwipcvo0=;
	b=E93zvxaJjM+gR+WMFAdYyFuUCqn3TAYc9ZxLK8t+0mRK7NvnAvDOqakFcsREdlVCVqic
	 FdnmtD9HXqYXhkocEXgTWpOGm1uINojvCqQLy8HXyiaqDhrSsAbBt+Eto3XqdBtpKkVhD
	 2mVWAi2KFSce4qcueJycWwpCj7V699hHd4GFyTf38PqFzacL4Suqxx+RG1ZKX5OHzLrER
	 /p8OTN5rClui/enUZ8/1xRo3B6KpX48zH7JEnI0NJQUOnhblnemwSRcJ90kjUlMRoyOm3
	 K1q+Kwdu7H8RjWuKzJdCtuQzBb1yOTd+ONuf3KnUjMMedbQhLuFGrNgmvhvlF+UFYhg==
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=inJSfAYG;
	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 44377606A31A
	for <netdev@vger.kernel.org>; Tue, 27 Oct 2026 22:47:09 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAE781F01825;
	Tue, 27 Oct 2026 22:47:08 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793141229;
	bh=BRhWps6yiPo6vqGKqMu5wMjShEbWK2OtLM+mwipcvo0=;
	h=Date:From:To:Cc:Subject:In-Reply-To:References;
	b=inJSfAYGOqiY43LEC4aYEatk1t9+uTRH7U4HgtLYiHqLP+Xo+UikC6cuh29ezbIcK
	 FumuJ9m40PiE3bQKvcRUjG/AhyCpNzic/E3yBmqa8Uaso3iX5Pkhw9YBLZJUJl+rKt
	 xAY+/7UJhGASOj61W06VC5NUmkmFZzFCxalIYvdzh1GvDM4ExRotILphtBQMjkZ/+e
	 5yG9CdzUK3GPktL81eRuzCq7IYP0cZlCVwsu0jx74E2YQB9LHrwlIIcCIsUiLBJAAK
	 Vf1RC8RiyIa1Ot0rksAD486g55mAEcekJhBZ0TBN9F06z9vmWEw5CvA9J58f8CIRVK
	 UcBGAG80aW0Tg==
X-Cc: netdev@vger.kernel.org, jacob.e.keller@intel.com, horms@kernel.org,
 pabeni@redhat.com, edumazet@kernel.org, davem@davemloft.net,
 jiri@resnulli.us, Guikun Yang <yangguikun19@qq.com>
X-In-Reply-To: <20261026174403.512-1-fmancera@suse.de>
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