* [PATCH] net: initialize sk_peer_lock in cloned sockets
@ 2026-11-18 8:49 Henry Martin
2026-11-18 8:52 ` netdev-bot+sinfo
0 siblings, 1 reply; 2+ messages in thread
From: Henry Martin @ 2026-11-18 8:49 UTC (permalink / raw)
To: Eric Dumazet, Kuniyuki Iwashima, Paolo Abeni, Willem de Bruijn,
David S . Miller, Jakub Kicinski, Simon Horman
Cc: netdev, linux-kernel, Henry Martin, stable
sock_copy() clones a struct sock with two memcpys that both include
sk_peer_lock. sk_clone() re-initializes sk_lock, but nothing resets
sk_peer_lock, so a clone created while the parent's sk_peer_lock is held
inherits the lock in the locked state.
The first getsockopt(SO_PEERCRED) on such a child spins forever in
queued_spin_lock_slowpath(). spin_lock() disables preemption, so the
task never schedules and its CPU stops reporting quiescent states; RCU
grace periods then stop and callers of synchronize_rcu(), such as
expand_files() from accept(), hang.
Initialize sk_peer_lock explicitly for the clone.
This issue was discovered by Tencent CodeBuddy Security.
Fixes: 35306eb23814 ("af_unix: fix races in sk_peer_pid and sk_peer_cred accesses")
Cc: stable@vger.kernel.org
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
net/core/sock.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/core/sock.c b/net/core/sock.c
index ad414878dc5b..b5e2a2a7741c 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2545,6 +2545,10 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority,
sk_node_init(&newsk->sk_node);
sock_lock_init(newsk);
+ /* sock_copy() copies the parent's sk_peer_lock verbatim, including a
+ * held state, so the clone must start with a fresh lock.
+ */
+ spin_lock_init(&newsk->sk_peer_lock);
if (lock)
bh_lock_sock(newsk);
--
2.43.7
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: initialize sk_peer_lock in cloned sockets
2026-11-18 8:49 [PATCH] net: initialize sk_peer_lock in cloned sockets Henry Martin
@ 2026-11-18 8:52 ` netdev-bot+sinfo
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sinfo @ 2026-11-18 8:52 UTC (permalink / raw)
To: Henry Martin
Cc: Eric Dumazet, Kuniyuki Iwashima, Paolo Abeni, Willem de Bruijn,
David S . Miller, Jakub Kicinski, Simon Horman, netdev,
linux-kernel, stable
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-18 8:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 8:49 [PATCH] net: initialize sk_peer_lock in cloned sockets Henry Martin
2026-11-18 8:52 ` netdev-bot+sinfo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox