Article View: linux.kernel.netdev
Article #25918[PATCH net-next] net: use RCU_INIT_POINTER() to clear sk->sk_wq in sock_orphan()
From: Jiayi Zhang
Date: Wed, 02 Dec 2026 18:03
Date: Wed, 02 Dec 2026 18:03
77 lines
13836 bytes
13836 bytes
sk->sk_wq is an RCU pointer: sock_graft() sets it with
rcu_assign_pointer() and readers such as unix_write_space() load it with
rcu_dereference(), possibly while the socket is being closed. When an
AF_UNIX socket is closed while its peer frees skbs charged to it,
sock_orphan() clears the pointer with a plain store and KCSAN reports:
BUG: KCSAN: data-race in unix_release_sock / unix_write_space
read (marked) to 0xffff888137738100 of 8 bytes by task 20918 on cpu 0:
unix_write_space+0xa6/0x170 net/unix/af_unix.c:603
sock_wfree+0x282/0x400 net/core/sock.c:2749
unix_wfree+0x1d/0x30 net/unix/af_unix.c:2019
skb_release_head_state+0x27b/0x280 net/core/skbuff.c:1167
skb_release_all net/core/skbuff.c:1187 [inline]
__kfree_skb+0x18/0x180 net/core/skbuff.c:1203
sk_skb_reason_drop+0xd6/0x270 net/core/skbuff.c:1242
kfree_skb_reason include/linux/skbuff.h:1330 [inline]
unix_release_sock+0x66f/0x790 net/unix/af_unix.c:759
write to 0xffff888137738100 of 8 bytes by task 20919 on cpu 1:
sock_orphan include/net/sock.h:2145 [inline]
unix_release_sock+0x238/0x790 net/unix/af_unix.c:711
The race has no functional effect. Readers handle a NULL sk_wq
(skwq_has_sleeper() and sock_wake_async() check for it), and a reader
that still sees the old pointer is safe because the socket_wq is part
of the socket inode, which is freed after an RCU grace period. The
plain store still lets the compiler tear it, and KCSAN reports it.
Clear the pointer with RCU_INIT_POINTER(), which stores it with
WRITE_ONCE(), as sk_clone() and sock_init_data_uid() already do.
Fixes: 43815482370c ("net: sock_def_readable() and friends RCU conversion")
Reported-by: syzbot+c2e012bd497ee37068b0@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=c2e012bd497ee37068b0
Signed-off-by: Jiayi Zhang <zhangjiayi1014@gmail.com>
---
The syzbot report is in syzbot's moderation queue and was not sent to
the lists; the Closes: link shows it.
Tested in QEMU with a test program that closes both ends of AF_UNIX
socket pairs at the same time after queueing messages (KCSAN report
filter set to these functions): without the patch 5 of 5 instances
reported this race on sk->sk_wq within 10 minutes; with the patch none
of 5 did. The net selftests were not run.
With the patch, 3 of the 5 instances reported another pair of accesses
under the same title: sock_set_flag(sk, SOCK_DEAD) in sock_orphan(),
a non-atomic __set_bit() on sk->sk_flags, against the test of
SOCK_FASYNC in sk_wake_async_rcu(). syzbot shows that pair in 3 of the
35 crashes of this bug; the other 32 are the sk->sk_wq race fixed here.
This patch does not change it.
mptcp has the same plain store of sk_wq in net/mptcp/protocol.c; that
would be a separate patch.
AI tools assisted with the analysis, the code and the changelog.
include/net/sock.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index 3144efa..669608d 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2142,7 +2142,7 @@ static inline void sock_orphan(struct sock *sk)
write_lock_bh(&sk->sk_callback_lock);
sock_set_flag(sk, SOCK_DEAD);
sk_set_socket(sk, NULL);
- sk->sk_wq = NULL;
+ RCU_INIT_POINTER(sk->sk_wq, NULL);
write_unlock_bh(&sk->sk_callback_lock);
}
--
2.53.0
Technical Details
Message-ID:
<20261202180315.4144359-1-zhangjiayi1014@gmail.com>Path:
mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.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-375986-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.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-375986-linux-kernel-netdev=dewy.ru
From: zhangjiayi1014@gmail.com (Jiayi Zhang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next] net: use RCU_INIT_POINTER() to clear sk->sk_wq in sock_orphan()
Date: Wed, 2 Dec 2026 18:03:15 +0000
Organization: Usenet Network
Message-ID: <20261202180315.4144359-1-zhangjiayi1014@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2027110"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:jP4h+BiA9do8aDIvEEQVV7rSbms= sha256:7pEajamEipuG5CJXpfx1jLHTLMEbY+gxEvW5bCiTdWA=
sha1:e9o9r/XkedxiS/I/oBJPFBOduBE= sha256:pgILsmYRlBINcew3g4k9ta3h2HqCoLApsV2SLtS9EUk=
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 B1D051176E9; Wed, 2 Dec 2026 21:03:42 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
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 Zcu6BC5fHBC6;
Wed, 2 Dec 2026 21:03:38 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375986-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 5F8A11176A7; Wed, 2 Dec 2026 21:03:29 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 7DAF527841; Wed, 2 Dec 2026 18:03:27 +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=1796234607;
b=tqZ9ZUwQoc+5spqYRy1iRuCm9+WWm8t6hOHKZv393P+ZMSXmWrgI8d60h0BUboc1MVUp
OxACklRsI8//Pg6ab9ICE7uzaO7pqekSJrgEWUxPtcVPJj8dWblqTapO5+dsX3fLxkgk5
yCUM0mIs+810ypuClH0Jpr1TyGxN0431/3tcpMdwQwbIZ8sJfhZn8qqMc1r9NFxabq3Oy
SP0IGdwOOgzf6i42yqlO85lvnXsJ8MSICsC2CAB7u+Uqk+sGk0Tzb7OY1rKZ+o9V89QXM
Ch30VET+SH6L30rOULXF1XuG4b0yfm5kyaqWsTxhIQlGMRUNrHJlPbH4ocdwihoxF1g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796234607;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:
List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
bh=0IVtpZILZozb5+TtvtpKi6eiQrMtIX3bSJ8yrqIXU48=;
b=bZakjIS7kBCRj63qYVUzgEYhv9qEsVcTfVM7KznhrzhsXWxJT1QCylDfSbk5zHdyZ7OX
S3kNk+0a44UhEPVHQrUA/559lyy6XEJDU+o9MiupN2C8tgOCswb/TMn4Cqax6eQi/95np
NBtTLvL8tSx+/9g8wciyG/ipMViMSfeuIJ0EcBqkzajrVV+MaM6bGP+C/8Mem/TikeGdj
p+rDWm236oroAYx/efNKcO0HB0UE3AYUq1etsrVoxp+cUXZyCCXMP/oe4F5Cr7FmWUUVG
ZWfIqKj2poDJLWjtOd+v1GlS3FSS4aSVGTygWUZ747mMfZJd3SdQEUzvMArDGt9hlLQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=BF1IuUur;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
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 4C723606A32F;
Wed, 2 Dec 2026 18:03:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=BF1IuUur
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.229.6
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796234606;
b=FC8SPNi4ytX/qE0EdfkA3cQUrSAeM3mTxRR9s7yLwxykMIDFwsEC4otdi7605EJF6D6n
MbCclM45bGk9BG/VdarJ51aW/qPly7PIUIv0S4p14bPse8Ki7ZMUpYq0Pzwrlmw/Mfy4h
GEFkU8zqafaJZqZr3YbvMWfv/EG+Ba7/2ZNB6zBW3SfwaC+c5QP1rMcpknDouhYy3rO8W
04sB0ad6Q/k2V8dgksb97Qf83096Nmf5gARcVySQc8K5f2tpc5oURyQMK8O1AykK0ASKc
dlr+0i+YPE6g+S7ur6k8B2AtoBe7i8yooNaNQVRxrqVVr1b/LKfDSZvDmuCYncpqtAw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796234606;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding;
bh=0IVtpZILZozb5+TtvtpKi6eiQrMtIX3bSJ8yrqIXU48=;
b=U5KXpaFuo/5oBbx4MUpIMSOc6GlOR98EuWSS2ShG11HVI+czO67ui/VqR5laxcLIEreP
z82pch5J6s+9eeICrvKt2p/j6lrSXpY3vIGgls2tNmMWLg1YLls7s8UhjrhF74gyYudRx
zPmKoXoPj5lN42gTHacEqpbLUh0TAMqGoHmfmlNhXZWR+g4h/sZY2pSkpouXMg+T9bJCH
F0H/aHfDd2IPOtVAFkDZEEQETuaJTc5vA0q4LUQfl//fHUIXyBpoa6dsJkkOzK1MB6XrN
J1Sj+npDJun4ZACahrw9o9/T3f8gF5UDbF0r+TZNaEg7E0NIveRX52bz5SzzqRbYNjA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=BF1IuUur;
arc=none smtp.remote-ip=74.125.229.6
X-Received: from mail-dy2-f6.google.com (mail-dy2-f6.google.com [74.125.229.6])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12297606A32C
for <netdev@vger.kernel.org>; Wed, 2 Dec 2026 18:03:25 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 12297606A32C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dy2-f6.google.com with SMTP id 5a478bee46e88-33e48934fa8so2563416eec.0
for <netdev@vger.kernel.org>; Wed, 02 Dec 2026 10:03:25 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796234605; x=1796839405; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=0IVtpZILZozb5+TtvtpKi6eiQrMtIX3bSJ8yrqIXU48=;
b=BF1IuUurVY1S9rRsP2Zed1nbDfWS+hjXvJvB8Ks8FrcmvFVwIqmWlV20aOpoCDDbOG
ElQtefyY7KZCcNzOZI9HPjXcCiFO3aRHbSdaKav3Jkzdivltl2c/HMDkqE+3C/GfW/g5
qDe2Ve+mDLgepUgfzwAdxpm/gxRyxNTbVRNv8RaKoH2jIJjIRPyXZX7o1U54M1/S6VWx
r44vFSyuZmCAi7gv77gT3joYcdG1yQXILfYOiQGGUjWRU1EnBf31oF1Ng1lI6XBdLCia
yIJ5hnMAEatoMx8VzJCx9dg9FXJl9apd8ZL5RVi6dNmo/ROfxDTbEkBbU3F4tkV6/pJY
IOxA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796234605; x=1796839405;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-g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nw3RSYCWtf67J+y64+8oREmS
2/ST8PRU+hMGrQPyXbq5CfTA7KeTPmw30sCYyLWftbA+BGgyVDgVg6Op3lw67slVw8nYRv9UPr8
7Rs36lcSIOVtv9iIIu2nc4e2iTsTRtMWsOW/WGHyvoiG5JAfBzuuAFAR
X-Received: by 2002:a05:7301:a0d:b0:369:fa21:ba0b with SMTP id 5a478bee46e88-38570847a85mr42972865eec.33.1796234604771;
Wed, 02 Dec 2026 10:03:24 -0800 (PST)
X-Received: from jiayi-vm-sprl-server17.local ([155.69.195.24])
by smtp.gmail.com with ESMTPSA id 5a478bee46e88-386f676c3ccsm43616567eec.12.2026.12.02.10.03.22
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 02 Dec 2026 10:03:24 -0800 (PST)
X-Cc: netdev@vger.kernel.org,
syzbot+c2e012bd497ee37068b0@syzkaller.appspotmail.com,
syzkaller-bugs@googlegroups.com
X-Mailer: git-send-email 2.53.0
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