From: Simon Horman <horms@kernel.org>
To: Lee Jones <lee@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
Ingo Molnar <mingo@kernel.org>, Kees Cook <kees@kernel.org>,
Junxi Qian <qjx1298677004@gmail.com>,
Samuel Ortiz <sameo@linux.intel.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] nfc: llcp: Fix use-after-free race in nfc_llcp_recv_cc()
Date: Fri, 1 May 2026 14:28:19 +0100 [thread overview]
Message-ID: <20260501132819.GD15617@horms.kernel.org> (raw)
In-Reply-To: <20260429134115.3558604-2-lee@kernel.org>
On Wed, Apr 29, 2026 at 01:40:42PM +0000, Lee Jones wrote:
> A race condition exists in the NFC LLCP connection state machine where
> the connection acceptance packet (CC) can be processed concurrently with
> socket release. This can lead to a use-after-free of the socket object.
>
> When nfc_llcp_recv_cc() moves the socket from the connecting_sockets
> list to the sockets list, it does so without holding the socket lock.
> If llcp_sock_release() is executing concurrently, it might have already
> unlinked the socket and dropped its references, which can result in
> nfc_llcp_recv_cc() linking a freed socket into the live list.
>
> Fix this by holding lock_sock() during the state transition and list
> movement in nfc_llcp_recv_cc(). After acquiring the lock, check if
> the socket is still hashed to ensure it hasn't already been unlinked
> and marked for destruction by the release path. This aligns the locking
> pattern with recv_hdlc() and recv_disc().
>
> Fixes: a69f32af86e3 ("NFC: Socket linked list")
> Signed-off-by: Lee Jones <lee@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
FTR, there is an AI generated review available for this patch on sashiko.dev.
I have looked over it and I believe it only covers pre-existing issues
and should not block progress of this patch.
next prev parent reply other threads:[~2026-05-01 13:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 13:40 [PATCH 1/2] nfc: llcp: Fix use-after-free in llcp_sock_release() Lee Jones
2026-04-29 13:40 ` [PATCH 2/2] nfc: llcp: Fix use-after-free race in nfc_llcp_recv_cc() Lee Jones
2026-05-01 13:28 ` Simon Horman [this message]
2026-05-01 12:58 ` [PATCH 1/2] nfc: llcp: Fix use-after-free in llcp_sock_release() Simon Horman
2026-05-01 23:27 ` Jakub Kicinski
2026-05-06 8:11 ` Lee Jones
2026-05-06 11:08 ` David Heidelberg
2026-05-06 13:51 ` Lee Jones
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=20260501132819.GD15617@horms.kernel.org \
--to=horms@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=qjx1298677004@gmail.com \
--cc=sameo@linux.intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.