Netdev List
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Henry Martin <bsdhenrymartin@gmail.com>
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
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	[thread overview]
Message-ID: <20261204192734.GC192805@horms.kernel.org> (raw)
In-Reply-To: <20261125080706.648722-1-bsdhenrymartin@gmail.com>

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>


      reply	other threads:[~2026-12-04 19:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  8:07 [PATCH nfc v3] nfc: llcp: reject bind and connect while the socket is still linked Henry Martin
2026-12-04 19:27 ` Simon Horman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204192734.GC192805@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=bsdhenrymartin@gmail.com \
    --cc=davem@davemloft.net \
    --cc=david@ixit.cz \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oe-linux-nfc@lists.linux.dev \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox