🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27101

Re: [PATCH nfc v3] nfc: llcp: reject bind and connect while the socket is still linked

#27101
From: Simon Horman
Date: Fri, 04 Dec 2026 19:27
42 lines
9793 bytes
On Wed, Nov 25, 2026 at 04:07:06PM +0800, Henry Martin wrote:
> llcp_sock_connect() only rejects LLCP_CONNECTED and LLCP_CONNECTING, so a
> socket that is still linked in local->sockets can be linked a second time
> into local->connecting_sockets.  That covers bound and listening sockets,
> and sockets that a peer moved to LLCP_CLOSED with DISC or DM.
> 
> Both lists use sk->sk_node.  When the peer answers with CC,
> nfc_llcp_recv_cc() removes the node from the connecting list and links it
> back into local->sockets, where the stale bind-time entry makes the node
> point to itself.  Every later sk_for_each() over local->sockets then spins
> forever with the read lock held, which pins the CPU and stalls RCU, and
> the socket is never freed.
> 
> The same stale-link case reaches llcp_sock_bind(): nfc_llcp_recv_disc()
> and the non-connecting branch of nfc_llcp_recv_dm() move a socket to
> LLCP_CLOSED without unlinking it, and bind() only checked sk_state, so
> it would link sk_node into local->sockets a second time.
> 
> Reject connect() and bind() while sk_node is still linked.  A socket
> has to be closed before it can be connected or bound again.
> 
> Reproduced on v7.4-rc3 as uid 1000: a soft lockup / RCU stall in
> nfc_llcp_sock_from_sn() while walking local->sockets.
> 
> This issue was discovered by Tencent CodeBuddy Security.
> 
> Link: https://lore.kernel.org/all/20261009092338.3146149-1-bsdhenrymartin@gmail.com/
> Fixes: a69f32af86e3 ("NFC: Socket linked list")
> Cc: stable@vger.kernel.org
> Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
> ---
> v2 -> v3: apply the same sk_hashed() guard to llcp_sock_bind(): a socket
>           that a peer moved to LLCP_CLOSED with DISC or DM stays linked
>           in local->sockets, and bind() only checked sk_state, so it
>           could link sk_node a second time (reported by sashiko's
>           review of v2).
> v1 -> v2: reject any socket that is still hashed (sk_hashed) instead of only
>           LLCP_BOUND, covering bind()+listen()+connect() and sockets left
>           linked after DISC/DM.

Reviewed-by: Simon Horman <horms@kernel.org>
Technical Details
Message-ID: <20261204192734.GC192805@horms.kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377585-linux-kernel-netdev=dewy.ru
References: <20261125080706.648722-1-bsdhenrymartin@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377585-linux-kernel-netdev=dewy.ru
From: horms@kernel.org (Simon Horman)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH nfc v3] nfc: llcp: reject bind and connect while the
 socket is still linked
Date: Fri, 4 Dec 2026 19:27:34 +0000
Organization: Usenet Network
Message-ID: <20261204192734.GC192805@horms.kernel.org>
References: <20261125080706.648722-1-bsdhenrymartin@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="2842572"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:gDRA8BzBiY9f6tEjsdveo2v9y7U= sha256:nRs8VIqg+1biXoIRldF5M9U/L/LNtji7Ho17jYFRR0Q=
	sha1:ZvDejOE4eaKNYUJA9db1AfJikcE= sha256:mJpUUwxoXtL1Ms4Qgk1yj+oc5WcpUiBPlicXwhCQL/Y=
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 8C6C2117CBA; Fri,  4 Dec 2026 22:28:00 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.642
X-Spam-Status: No, score=-3.642 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.142, 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 Gc-LQhLXsv0B;
	Fri,  4 Dec 2026 22:27:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-377585-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 05059117CAD; Fri,  4 Dec 2026 22:27:47 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 23E93608FC8; Fri,  4 Dec 2026 19:27:47 +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=1796412465;
	b=qXOUOl3PyQi4OBE1LKdWPsvFpvTuV5smoAypYTbueX28PWKpX/+hnyKZ3ddyDxJJURXY
	 JwAk8Nzlzu2MmDrSP7AsBY85QaLgqnj9LnkZUqz+IP1o9BmzJ8+7KfYVm55opd1nSLXPj
	 DD8FJlI2pLjzdFDaWqmDLRcEhrruV9dxMYL9pTGnACwnIT5PYs1r79Ka7te4mF/4qsqKV
	 H7zhhtU4igTs64bpYpW6H1V8S0BQI5sEIIaOF8uPgKEKr+mF8de3GTv+u1zbab+0vbAR0
	 JTNXDwtpihKyYnc/AyByOZzjahg/4k1OFdul2f8I4F9n4lrfJX26up/3WEpkBdE0NYw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796412465;
	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=G5Dr77alHupzr5LGit7sNmbcBnMJlw3SdHcMNEsktBs=;
	b=uMqAhA1l00gNNmC83uidbczzpxmlAsLjU3YH/nVeCudToORn4XMmQ5/jNNFit5bkHYfG
	 cp6Qe8tk24ZBaJHFKXTZsRWFlGq3Rk/RlSSmBN3BrgEr56Kf57xi1875smKMYXVWuKtmW
	 a7OSQlhajHeZq9slaJhre9HL10rcZl1BHHjinflWVx4t1JFidNK0ajv+ptbij3P4mXgDW
	 EsvAzZMUUxXsneeqri4jWFo/pnZsqPdaHhqskC1CYRSungyFlJxuvnfKd8jJ8d4szGlnb
	 ZpTu+mJyvvM85KHFnFGlYl3G2sKH44Edcb5jWsPBwBJ0C0lJN3ckroD0I4CY0N0Q38A==
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=ekRyBidC;
	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 5F8E3606A336;
	Fri,  4 Dec 2026 19:27:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ekRyBidC
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=1796412459;
	b=Da4jkJ7PQjr+sn+S+chQnLBr14CkAfucrszZb/dr00sLvZK3nYaB+wuzalceqnMNAahb
	 zCWzfh18VZKvZrS+9WC8O+DG0kdH7QCMIDUxWQ00DsH/AQ33FlaxDKEU/bEs+Vm0Y/Aoy
	 ZJ0qr4PmyuZfIqfr3F02wvvX34ZDzPPKRyNANm6LDHtnZnQasoJK4bczkqlSyiE63GpU3
	 941N3qUZNFdtqOO9VjkX9WnYFbSmeSYn0Y2TpqWnjSEwo8lQMUVlQDhqwn5f8Z6B4SWMA
	 SHZ0rqwOzFc5YVCUh6+2AflbMyIBRyVpwh3PMhxOFi4HuJu1C2GY9Yv6NdwyBqx6wGA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796412459;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=G5Dr77alHupzr5LGit7sNmbcBnMJlw3SdHcMNEsktBs=;
	b=vF8+ieiLSRvKgVfZXo/HrT5+JK4wDXr+5CjZs3nWeukAGG75JQT8enM96ZU/9FWNFPfH
	 10m0L5KkOGB7cBwR+iup15A1m9k0V2uLExXEDnLDWPpDnfulp9GTx7OQt6ZPCn8HKfYsv
	 EZKCiAnxSSf/QO7ZtWO20boL1BI6ItQUB/SFGazeWn11XIcorMlg4aXZF7odRi4BHr2jS
	 xyekAhL2mTXZyFaW0MYUMHdCfGv1X+UWZG9VP1/XVycaVzkTOzNWgd5kYTj8DvLUDaF7G
	 uLaU7Y+uslpwZ61RWT5vqQAA5Fq9MaH7ft8yCBBi5ENXnPDA1GmCSzIXMHoL3Nirp6g==
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=ekRyBidC;
	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 7AB92606A322;
	Fri,  4 Dec 2026 19:27:39 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A1801F00936;
	Fri,  4 Dec 2026 19:27:37 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796412459;
	bh=G5Dr77alHupzr5LGit7sNmbcBnMJlw3SdHcMNEsktBs=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=ekRyBidC1GCyktlrWMaK+Dkb0geSNopxbmGMRxd9Euq4w6aPSZXEHXo4rRJIyy7we
	 GvFmwdlbu8DVkKVCEXmcdDqVExI20eky6UKJfdS30oe7kSg2Jqv2dxtf0OHUH4dS6Z
	 QtcaUnxLSksO90VGVnAMB2LVqFhExHcsZW+P/vEXENbpIFbXBjlRlqQfCZiBjGGC4L
	 O1bgVoUDMdpCH8H+ZFUbS+irMKZ1JMb2m+Q1XRXCSeXHaivsRi6oD3bvO7xhLyU74B
	 emlc91hWKi3MCeVW3LqtvRd9Zsffc1X1ugJEhiHBFliy0Gd2G5GDzSEt9BUSSrK7Nk
	 lJXvItWUHGxTQ==
X-Cc: david@ixit.cz, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, oe-linux-nfc@lists.linux.dev,
	netdev@vger.kernel.org, stable@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: <20261125080706.648722-1-bsdhenrymartin@gmail.com>