๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8517

Re: [PATCH net 1/1] nfc: digital: fix use-after-free in unregister

#8517
From: Simon Horman
Date: Thu, 29 Oct 2026 10:22
29 lines
9513 bytes
On Mon, Oct 26, 2026 at 03:24:07PM +0800, Yuqi Xu wrote:
> nfc_digital_unregister_device() cancels its own workqueue items and
> then frees every queued digital_cmd. A command already submitted to
> the driver remains the argument of the async completion.
> digital_send_cmd_complete() can still assign cmd->resp after that
> object has been freed, which is a use-after-free.
> 
> Abort the in-flight driver command before reclaiming the queue, and
> drain the completion work the driver may schedule from abort. Once
> the nfc device is shutting down, do not queue or submit another
> command: finishing the aborted one would otherwise hand the next
> queued command to the driver while it is being freed.
> 
> Port100 and nfcsim invoke the digital completion from a private work
> item, so flush that work before abort returns. trf7970a completes from
> a delayed timeout work and from its IRQ thread; handle its MD listening
> state in abort and shutdown, and stop the timer before the device is
> released. st95hf's IRQ thread can observe that remove already ran and
> must not call back into the freed command.
> 
> Fixes: 59ee2361c924 ("NFC Digital: Implement driver commands mechanism")
> Cc: stable@vger.kernel.org
> Reported-by: Vega <vega@nebusec.ai>
> Assisted-by: LLM
> Signed-off-by: Yuqi Xu <xuyuqiabc@gmail.com>
> Reviewed-by: Ren Wei <weir@nebusec.ai>

Reviewed-by: Simon Horman <horms@kernel.org>
Technical Details
Message-ID: <20261029102221.GF257209@horms.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-353235-linux-kernel-netdev=dewy.ru
References: <cover.1791172164.git.xuyuqiabc@gmail.com> <1792999448.107874-2-xuyuqiabc@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-353235-linux-kernel-netdev=dewy.ru
From: horms@kernel.org (Simon Horman)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 1/1] nfc: digital: fix use-after-free in unregister
Date: Thu, 29 Oct 2026 10:22:21 +0000
Organization: Usenet Network
Message-ID: <20261029102221.GF257209@horms.kernel.org>
References: <cover.1791172164.git.xuyuqiabc@gmail.com>
 <1792999448.107874-2-xuyuqiabc@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="1984012"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:EpMvnt/7Y2APO7oY5AsZiuI1uDk= sha256:SmIa4gtFm4lqADXQLG7kOQ8UOCZt6g5QeSCpp9rMwoI=
	sha1:J6hyf1kgdDJtj7n0PGvG9Rwx9wI= sha256:WhdfZKrSMT+J53cBcj5EtCDKyiO915UQpvxZy70rX6s=
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 370E7125C60; Thu, 29 Oct 2026 13:27:35 +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 Sraql3kLpgNV;
	Thu, 29 Oct 2026 13:27:32 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353235-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 6FEEB125C5F; Thu, 29 Oct 2026 13:27:22 +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 E254726161; Thu, 29 Oct 2026 10:22:34 +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=1793269354;
	b=TAMRxg1q7/Lk49ZtOif+1edwycT663iVZZi/2bsy9dGY/kpJM9UscVPWM7B+iOMA2ZTL
	 za/sbSYAkgEUdRPckSRXA9QIaWkxHumOuzgH96SXl66DpR7xjxeApDJMGfvTO9YZECESH
	 pu6ncUvpplxZw/vNCYkK3+B4EeazRJSU97J/P88wyYmoQM5aXYNkkmBP6Xutiy8cTLLmO
	 /uzDUZuKIzteSCtK7m9NkuIZanx4b3kLTKg1BFKYqEVzGmOyzeXpDngjETy7j6aalaD1S
	 VvvB6u0MABqLC1dRFKXqJkicaBisgreEcTsImYny/yLaHG1lUFMRKAs2UPKFMd+N3ww==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793269354;
	h=X-Original-To:Received:Received:DKIM-Signature: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:In-Reply-To;
	bh=WEwZYcuaAT+y33Zr9c1xlmb2GPWDUVDkk4ZHB+IYvgk=;
	b=dy7eRTuvlPHPPA5A0Itp3VSQA5XlLdIOKT+/cp9hMk8+/tNRseJaoyPr0JJ2qbIYCiEB
	 Wf3yJ3dOO2Q+oMz28uufCuBUBpDJYYZ0DkMDSSluDJNne+KgXCTD8pfzh16HAEC9deJh/
	 9E2cllwxj50ce5bntTLmiZeCvU48d4ekQx8nvDTaZBLWgi1yzFmxJnAbyy507crZDmm8R
	 nskSO6ilmF60HLWoGWaG9InZy9LeKRIXHpomPSy+tS8DxYjiSvjPCxJC81WQwMSbI/h0X
	 P8t95/ow/rYaQbjXpaA/3eMPW6uvSvaJfgGTnUMkFY38lSqB9C8NW/K4nVM8dcph25A==
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=MPF6fhoF;
	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 1A2E3606A323;
	Thu, 29 Oct 2026 10:22:34 +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=MPF6fhoF
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=1793269348;
	b=IU9kQhrXLxAnDJX9ZEN3sGGmfXxFh/b7D6k/OKzJgDxwu99xQab+6cxFeP6IIGZXSVUD
	 HNK4DgnD5LXdsVYMwl5gyM/kBylRVHTNT5up4HOOwe5JgNP6xfKh6Um7o/2FFJ5zYjV5W
	 2Jb4SFUS3gPvjKn6WZPTafh1PdHQtzL0sZGMrZRsM0WL/ithg6mfoM6U69TA5I1GhVUze
	 MOB32/9n/qMtuCr1ddGmwhfDnAWNRzhYp70F3kI37A+Uo/A5ltR4Dmg63kglji8IZRh9Z
	 7iaUSrGniMsagxGyNp3noJesF0+hi+LcNYEzkkG/xTV41kkB63oZPcma4ywBM2uPs9A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793269348;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=WEwZYcuaAT+y33Zr9c1xlmb2GPWDUVDkk4ZHB+IYvgk=;
	b=lDqLGN5m++Ee2HCXBds95aCllht10FTwNU13mBMF4P+UoYcHNSZ9dDchok4uziAQsAmR
	 j/drK/XudJWqltPNeKuQ3ouqFhKJE0A9zyvdqrM5OMxl1UoFOU6vLrp71HFLgbMOvMPtj
	 Xzl3m4+IS/nAWaOS8INwPZT+gouLugvv2FOpdwIyzg8wnpMrx8P+sAjoo2/qINK3veMyW
	 E6gFrlshZ5WINZkKwly1Y8mvc24FjTK3FNvAGSOGjTV0njwxwQ21pSOWNXrpUvFKjhJ5i
	 f0cT1Pbe2k3L1Bje1IyfXZ1OeEFnHD2CEkI3mF5uRGfyH31iuhv2bJfq4nA4bJ71VXw==
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=MPF6fhoF;
	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 EB94D606A31C;
	Thu, 29 Oct 2026 10:22:27 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 847EA1F031E2;
	Thu, 29 Oct 2026 10:22:24 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793269347;
	bh=WEwZYcuaAT+y33Zr9c1xlmb2GPWDUVDkk4ZHB+IYvgk=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=MPF6fhoFkWfuyQjAe7WGw6laZy2mxakETrlJlKqo4IRk35lXolhaqzyyy9EJwGvAn
	 pLxk8G19UjPsn0azqFHr/Bqg1Ty9kcG8WAVKDzUcjVYgsUrBZbbCfJ8w0icEkzeWPA
	 BR9ilbaSCQYnxnn04Zx7j65i6GUQQ453gmNBQAuL/cupDMmlRXwmD2zDgH+ZY41MVb
	 qjd1hNMhQfkn0VDXqZZ6EeK2joF27g+p9VEaEuBCVZ6NirEbPf5goabuJXyuKqNG3Y
	 X5SGXqZkX1++SwtKjvR9Qg6PwBBmRH2bucMB35ZXPQ9SNz5EoWQaJWED1bWcb/AS70
	 mOoN4e3/7VmKg==
X-Cc: netdev@vger.kernel.org, oe-linux-nfc@lists.linux.dev,
	David Heidelberg <david@ixit.cz>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	stable@vger.kernel.org, Vega <vega@nebusec.ai>,
	Ren Wei <weir@nebusec.ai>, xuyq21@lenovo.com,
	Mark Greer <mgreer@animalcreek.com>,
	Uwe Kleine-Kรถnig (The Capable Hub) <u.kleine-koenig@baylibre.com>,
	Ian Ray <ian.ray@gehealthcare.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Thierry Escande <thierry.escande@linux.intel.com>,
	Samuel Ortiz <sameo@linux.intel.com>
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: <1792999448.107874-2-xuyuqiabc@gmail.com>