Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Henry Martin
Wed, 18 Nov 2026 08:38
[PATCH] nfc: llcp: walk the accept queue under the socket lock
Author: Henry Martin
Date: Wed, 18 Nov 2026 08:38
Date: Wed, 18 Nov 2026 08:38
53 lines
12288 bytes
12288 bytes
llcp_accept_poll() walks parent->accept_queue and reads each child's
sk_state without holding the socket lock. nfc_llcp_accept_dequeue()
unlinks closed children and drops their creation reference under that
lock, and the last sock_put() frees the child.
A poll() racing with accept() therefore reads a freed child:
BUG: KASAN: slab-use-after-free in llcp_sock_poll+0x440/0x4e0
Read of size 1 at addr ffff888112387812 by task poc.bin/528
Allocated by task 198:
nfc_llcp_sock_alloc
nfc_llcp_rx_skb
Freed by task 529:
__sk_destruct
nfc_llcp_accept_dequeue
Take the listener lock around the accept queue walk.
This issue was discovered by Tencent CodeBuddy Security.
Fixes: d646960f7986 ("NFC: Initial LLCP support")
Cc: stable@vger.kernel.org
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
net/nfc/llcp_sock.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index 1e5ee4bcde68..3503f1a7a7cc 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -584,8 +584,16 @@ static __poll_t llcp_sock_poll(struct file *file, struct socket *sock,
sock_poll_wait(file, sock, wait);
- if (sk->sk_state == LLCP_LISTEN)
- return llcp_accept_poll(sk);
+ if (sk->sk_state == LLCP_LISTEN) {
+ /* nfc_llcp_accept_dequeue() unlinks and frees closed children
+ * under the listener lock, so the queue can only be walked
+ * with that lock held.
+ */
+ lock_sock(sk);
+ mask = llcp_accept_poll(sk);
+ release_sock(sk);
+ return mask;
+ }
if (sk->sk_err || !skb_queue_empty_lockless(&sk->sk_error_queue))
mask |= EPOLLERR |
--
2.43.7
Re: [PATCH] nfc: llcp: walk the accept queue under the socket lock
Author: Eric Dumazet
Date: Wed, 18 Nov 2026 11:05
Date: Wed, 18 Nov 2026 11:05
38 lines
10178 bytes
10178 bytes
Le mer. 18 nov. 2026 ร 09:38, Henry Martin <bsdhenrymartin@gmail.com> a รฉcrit :
>
> llcp_accept_poll() walks parent->accept_queue and reads each child's
> sk_state without holding the socket lock. nfc_llcp_accept_dequeue()
> unlinks closed children and drops their creation reference under that
> lock, and the last sock_put() frees the child.
>
> A poll() racing with accept() therefore reads a freed child:
>
> BUG: KASAN: slab-use-after-free in llcp_sock_poll+0x440/0x4e0
> Read of size 1 at addr ffff888112387812 by task poc.bin/528
> Allocated by task 198:
> nfc_llcp_sock_alloc
> nfc_llcp_rx_skb
> Freed by task 529:
> __sk_destruct
> nfc_llcp_accept_dequeue
>
> Take the listener lock around the accept queue walk.
>
> This issue was discovered by Tencent CodeBuddy Security.
>
> Fixes: d646960f7986 ("NFC: Initial LLCP support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
> ---
> net/nfc/llcp_sock.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
Next time, please specify the target tree in the subject ([PATCH net]).
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Also, make sure to wait a least 24 hours between versions (
Documentation/process/maintainer-netdev.rst )
Re: [PATCH] nfc: llcp: walk the accept queue under the socket lock
Author: Jakub Kicinski
Date: Tue, 24 Nov 2026 02:15
Date: Tue, 24 Nov 2026 02:15
5 lines
7945 bytes
7945 bytes
On Wed, 18 Nov 2026 12:05:01 +0100 Eric Dumazet wrote: > Next time, please specify the target tree in the subject ([PATCH net]). FWIW we don't take nfc patches directly. So [PATCH nfc] I guess
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads