🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25211

[PATCH net v3 0/2] net/x25: don't call lock_sock() from softirq in x25_kill_by_neigh()

#25211
From: Martin Schiller
Date: Tue, 01 Dec 2026 12:01
105 lines
15215 bytes
x25_kill_by_neigh() takes lock_sock() on all sockets of a neighbour,
but it also runs in softirq context when the link layer reports a
disconnect or the peer restarts the link. syzbot hits this on mainline,
net, net-next and the LTS trees. A plain "ip link set lapb0 down" with a
connected peer is enough: LAPB sends a DISC, and the peer clears its
calls from softirq.

Patch 1 is based on Nguyen Ngoc Thang's fix [1]. Sockets that are not
owned are cleared right away under the socket spinlock, owned sockets
are flagged and cleared from a new release_cb, and NETDEV_DOWN still
waits for owners. A flagged socket no longer matches incoming frames and
no longer transmits, so a new call on its LCI after a restart reaches
the listener, and child sockets do not inherit the flag. v3 addresses
the AI review of v2 [6]: the flag is only cleared once the socket's LCI
has been reset, and transmissions in process context and the backlog
processing take the socket spinlock, so that an owner cannot send
frames of the old call after the restart has been confirmed.

Patch 2 fixes a pre-existing NULL pointer dereference in x25_sendmsg(),
x25_output() and x25_recvmsg() after they retake the socket lock. The
AI review of v1 [2] pointed out the first two, Krystian Kaniewski found
the x25_recvmsg() case and reproduced all three at runtime [7]. It does
not depend on patch 1. The AI review of v2 also notes [8] that a
reconnect on the same socket while x25_output() waits would pass the
new check; that is a separate, pre-existing issue that this series does
not address.

Deferring the whole cleanup to a workqueue [3][4] also avoids the
splat, but the restart is then confirmed while the old calls are still
bound to their LCIs. [5] had the same design as v1. Both have been
withdrawn in favour of this series.

Tested in QEMU (single CPU) with lockdep and DEBUG_ATOMIC_SLEEP, using
two lapbether devices on a veth pair. A sender stalled in x25_sendmsg()
via userfaultfd keeps the calling socket owned during the link event:

                                       unpatched  v1    v3    wq [4]
  1  link loss, calls idle             splat      ok    ok    ok
  2  link loss, caller owned           -          FAIL  ok    FAIL
  3  restart, caller owned, then a
     CALL REQUEST on the caller's LCI  -          FAIL  ok    FAIL
  4  ip link set lapb0 down            splat      ok    ok    ok

In test 2, the old call brings the link back up (SABM) before it is
cleared. In test 3, the new call does not reach the listener, and the
old call sends a DATA packet on the reused LCI.

Tests 2 and 3 were not run unpatched, as that kernel would sleep in
softirq. With v3, lockdep reports nothing in these tests, including the
new uses of the socket spinlock. Krystian tested v2 with the syzbot
reproducers of both reports, also with the PREEMPT_RT config of the
second one [7], and Shuai Liu tested and reviewed v2; their tags are
kept for patch 2 only, as patch 1 changed. The two races fixed in v3
are not covered by a test.

Changes in v3:
- clear X25_KILL_FLAG only after x25_disconnect() has reset the LCI
- take the socket spinlock around transmissions in process context and
  around the backlog processing
- update the comments of __x25_find_socket() and x25_new_lci()
- patch 2: describe the runtime reproduction, add Tested-by and
  Reviewed-by
- Link to v2: https://lore.kernel.org/all/20261127-x25-kill-by-neigh-v2-0-c7cdcc9f1320@dev.tdt.de/

Changes in v2:
- skip flagged sockets in __x25_find_socket()
- no transmission from flagged sockets in x25_kick() and
  x25_write_internal()
- clear the flag in x25_make_new()
- add the current syzbot report
- new patch 2

The changes on top of v1, patch 2 and the tests were prepared with the
help of an AI assistant (Claude, Anthropic).

[1] https://lore.kernel.org/all/20261001150118.128470-1-ngocthang2710.1999@gmail.com/
[2] https://lore.kernel.org/all/179121364205.434549.10310203820251738113@kernel.org/
[3] https://lore.kernel.org/all/tencent_F7C2DC0FA42B5866E5C39A9E70D3C52C2609@qq.com/
[4] https://lore.kernel.org/all/tencent_8BA4FF587EE5579AB67149C5062618DC7109@qq.com/
[5] https://lore.kernel.org/all/00f667e3-a158-4fb5-84a3-9ecda4718ce8@mail.kernel.org/
[6] https://lore.kernel.org/all/179585053119.3135.1065383095936227619@kernel.org/
[7] https://lore.kernel.org/all/5ad2c46b-4ed9-4689-950f-93753fa1586e@gmail.com/
[8] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127-x25-kill-by-neigh-v2-0-c7cdcc9f1320%40dev.tdt.de

---
Martin Schiller (1):
      net/x25: re-check x25->neighbour after re-acquiring the socket lock

Nguyen Ngoc Thang (1):
      net/x25: don't call lock_sock() from softirq in x25_kill_by_neigh()

 include/net/x25.h  |   1 +
 net/x25/af_x25.c   | 123 +++++++++++++++++++++++++++++++++++++++++++++++------
 net/x25/x25_in.c   |   7 ++-
 net/x25/x25_out.c  |   9 +++-
 net/x25/x25_subr.c |   4 ++
 5 files changed, 129 insertions(+), 15 deletions(-)
---
base-commit: d73525e6950b982fb67c74a1a64163529305a003
change-id: 20261124-x25-kill-by-neigh-2b70f6d19961

Best regards,
-- 
Martin Schiller <ms@dev.tdt.de>
Technical Details
Message-ID: <20261201-x25-kill-by-neigh-v3-0-7f05bdff15b1@dev.tdt.de>
Path: mbox-mo1.pugleaf.net!srv.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-374999-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.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-374999-linux-kernel-netdev=dewy.ru
From: ms@dev.tdt.de (Martin Schiller)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v3 0/2] net/x25: don't call lock_sock() from softirq in
 x25_kill_by_neigh()
Date: Tue, 1 Dec 2026 13:01:22 +0100 (CET)
Organization: Usenet Network
Message-ID: <20261201-x25-kill-by-neigh-v3-0-7f05bdff15b1@dev.tdt.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="1703793"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:aGp+u5AQsOP2CDt7GNOfVDmrzLQ= sha256:3RUy2K3Ll+RU+XJSymLHxcQTE7SHnXQlKNnORdf7/1U=
	sha1:oVXLKtcFc1OTTTuEkKicNxoajI8= sha256:XzAJYr02ujcI2IC+bvLI4PUXkR8AX3PjTXN/N+oF49M=
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 5B90211735E; Tue,  1 Dec 2026 15:02:23 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 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, 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=dev.tdt.de
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 9RgDJABkuxkB;
	Tue,  1 Dec 2026 15:02:19 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374999-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=dev.tdt.de
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 1C7FC11735C; Tue,  1 Dec 2026 15:02:11 +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 665A032F1E; Tue,  1 Dec 2026 12:02:03 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1796126522;
	b=AVOhwbA58wZVBxFGkn/Ns6W+Xg5LCQBIjmQBe+qRwR88eBloSk/RA28OtB1YxiQa4pii
	 Hh4u6X0UBK7WeRBB5GvjBhlpmTyq9shUpEXZoKTWkZrdkijSwji80hquDCzfjjsVWdJeX
	 Nt5L56fSvz0+yP2xrG3wC9JOELeQ7xK88TQrW+OjQ+u6GDOLnPw/v6NwjkpXATScKmU2V
	 CgaMLxangO5zQKC2tfH3K0cmTEis7qHu1ZfU9NHr/HxFb3csL7z3feg+yueluGwJrtOpK
	 4I2PfJujzDiyZUU+jBaeZobbhEEbEdnJJXqA6hJU4a3zOQhNNcXAOEPOAPx3i9kFhqg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796126522;
	h=X-Original-To:Received:DMARC-Filter:Received:Received:DKIM-Signature:
	 Received:Received:Received:From:Subject:Date:Message-ID:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-purgate:X-purgate-type:
	 X-purgate-ID;
	bh=V+6qK7Adl+7IFD24OGOYjD9iMw6vWoUxxf+SbigfbYs=;
	b=f9QF9mTHWkHFRntfbiIF/ydEUnUUbZ30Dgibn9RPWYv2vL0e9URshnuUCnj4/NxQ8WKc
	 JVN+pJ5tRlTaCX97UQlUEqfNt/8AbGhXnCjE7caFKmpVsHHhcpuL5rzmum3HeA9WQ4nu7
	 rrGDL9ftr4bnuo+p159nFyz2hBAAFnWwmJNg2gtbQmE9ms/eP+tARQuU1EgJH2aSPinpT
	 ej1W1EZFruBOQ3NADsn0nAs3Fuk5l3TCwVQiPH2tU5KGcRHpKBsLvREEboitjWnpKGdtg
	 ROEgga4g50f/5THB1CXvmAatDo16BoCqzlGfz6M/BAMu6+m1Qc7ya/5jR5nbV+YGyIg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=dev.tdt.de header.i=@dev.tdt.de header.a=rsa-sha256 header.s=z1-selector1 header.b=rfBhv+Rk;
	dmarc=pass header.from=dev.tdt.de;
	spf=pass smtp.mailfrom=dev.tdt.de;
	arc=fail 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 65BCD606A687;
	Tue,  1 Dec 2026 12:02:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=dev.tdt.de header.i=@dev.tdt.de header.a=rsa-sha256 header.s=z1-selector1 header.b=rfBhv+Rk
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=194.37.255.70
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796126521;
	b=iqH0g0y0uH4PspsTX69TgDi3FDARZSNam5qnI5E/JpjvX33KZO+ieVIedUFU/m4xp9yZ
	 dXfid/RNxXWslWk/8jmChZv14/jfUhSy0TL5/fKDrTXbbfzbg/ULVPGE4tET3ZentppsV
	 aO9lMCMkyytVcluJXKuQUBbGCIFp1NmyICdTJerMLIaBJHK2jefCp+l2CZhA9Zy0TgEeq
	 KxcUH4Bad3/T08qHXxovRVDA4FhNz66K9rD4kl+kKpmf4YKij6H34Njfy8Dt5nLHxxVi7
	 mWS2Yb9BufXvdraHVw2hEVQ3BoHcE7mXmaUr6UIyi/vm24owm0R3LYiutBvwYlFWN6g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796126521;
	h=DMARC-Filter:Received:Received:DKIM-Signature:Received:Received:
	 Received:From:Subject:Date:Message-ID:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Spam-Status:
	 X-Spam-Checker-Version:X-purgate:X-purgate-type:X-purgate-ID;
	bh=V+6qK7Adl+7IFD24OGOYjD9iMw6vWoUxxf+SbigfbYs=;
	b=cpB0xu9nX5Bl0tCQ1eJacWwE/9R0X5pa9N5EW/TqTWncwr/7pVVfMAptDhb94j5BxYSN
	 5IwaYgTie5+EwuLNC6q3gazhTHgxgPF5t6bjdy5VaCyuGu927L8HtUoy25bsEgwgY1/Gu
	 X62qqfpxIeaxljgBMfzNrn6A/AiExT+kaVFV9HAbxyy2LY+J5TzrUw4uUwLwE9Z0iSXCc
	 hh7LSAgYlzCfEo4YWXxorliceMT9IFBJf3p71nZ3fdDdxPKZq9nQzxFaiLyz2lu8YaMLt
	 WhSv9WwABKxwLHsU6QdYnpRYkoiYhlhdT9Y7vG+aDz2i6Aos7JVGYtYyiNg1E+qPoXw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=dev.tdt.de;
	spf=pass smtp.mailfrom=dev.tdt.de;
	dkim=pass header.d=dev.tdt.de header.i=@dev.tdt.de header.a=rsa-sha256 header.s=z1-selector1 header.b=rfBhv+Rk;
	arc=none smtp.remote-ip=194.37.255.70
X-Received: from mxout70.expurgate.net (mxout70.expurgate.net [194.37.255.70])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E506606A327;
	Tue,  1 Dec 2026 12:02:00 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3E506606A327
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=dev.tdt.de
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dev.tdt.de
X-Received: from [194.37.255.9] (helo=mxout.expurgate.net)
	by relay.expurgate.net with smtp (Exim 4.92)
	(envelope-from <prvs=6809d4f748=ms@dev.tdt.de>)
	id 1xYMYC-009MbB-L4; Tue, 01 Dec 2026 13:01:36 +0100
X-Received: from [195.243.126.94] (helo=securemail.tdt.de)
	by relay.expurgate.net with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
	(Exim 4.92)
	(envelope-from <ms@dev.tdt.de>)
	id 1xYMYA-00ENCl-UQ; Tue, 01 Dec 2026 13:01:34 +0100
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev.tdt.de;
	s=z1-selector1; t=1796126494;
	bh=V+6qK7Adl+7IFD24OGOYjD9iMw6vWoUxxf+SbigfbYs=;
	h=From:Subject:Date:To:Cc:From;
	b=rfBhv+RkpIP+O3DtlcjTnwcEKVh02a9EYWBbhkzNQj5KcoDFUo0dFWwHnDXKFDsXm
	 c2kM9uq2KWbj60sI/Jqyc9nFSOMP/7/qR2swz6PjVfE1S6LDVS3Cst2T5ZmIkh62XX
	 PIX6ThnaWTxh7Jt7xrDLn4NCEBS9AIWvXXUeS/UV9el1gADvCm19BmYFMPNkVoqNfI
	 XNtS+rywMj8mh8a5NS11NJoI5Ie+wQMxAScCF11nokwpH5OiFwXFPrHdDyWSxLPc7d
	 RRUDfMercMpHpVAuL++78tE6fOe9UbHUlrt/4pl1Zqb8GOxJPkwrJxF25i3cOGE49H
	 ljvq44vzGTLrg==
X-Received: from securemail.tdt.de (localhost [127.0.0.1])
	by securemail.tdt.de (Postfix) with ESMTP id 370B1240041;
	Tue,  1 Dec 2026 13:01:34 +0100 (CET)
X-Received: from mail.dev.tdt.de (unknown [10.2.4.42])
	by securemail.tdt.de (Postfix) with ESMTP id 1C541240036;
	Tue,  1 Dec 2026 13:01:34 +0100 (CET)
X-Received: from [127.0.1.1] (unknown [10.2.3.19])
	by mail.dev.tdt.de (Postfix) with ESMTPSA id AA46F2B315;
	Tue,  1 Dec 2026 13:01:33 +0100 (CET)
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
X-B4-Tracking: v=1; b=H4sIABK3DmsC/22NwQqDMBBEf0X23JVkbRV76n8UDzVZdanEkoSgi
 P/eID32+GaYNzsE9sIB7sUOnpMEWVyG6lKAmV5uZBSbGUhRrTVdcaUbvmWesd/QsYwTUt+ooba
 6bWsNeffxPMh6Op/gOEKXw0lCXPx2/iQ6q5+y+aNMhApNY6wx7aArUg/LqYw2lpahO47jC8Wjl
 6y4AAAA
X-Change-ID: 20261124-x25-kill-by-neigh-2b70f6d19961
X-Cc: linux-x25@vger.kernel.org, netdev@vger.kernel.org,
	Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>,
	Shuai Liu <847807867@qq.com>,
	Krystian Kaniewski <krystianmkaniewski@gmail.com>,
	syzbot+300375dfd44665f063a6@syzkaller.appspotmail.com,
	syzbot+9faa82ae2e94c5c7d2ef@syzkaller.appspotmail.com,
	linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev,
	Martin Schiller <ms@dev.tdt.de>
X-Mailer: b4 0.14.2
X-Developer-Signature: v=1; a=ed25519-sha256; t=1796126493; l=5204;
 i=ms@dev.tdt.de; s=20260220; h=from:subject:message-id;
 bh=t0ZC4/wnXaTKyKmJOLDjj+/f9jB26w1bKs/PYuHpVzY=;
 b=6TCU4HhHp9BQOpm7tbAR3iwISpfKYWerAWhzz9iPopGEhd7oTURzsXhl8wzTrvkdzkEbl8O5Y
 AqRq34xX4pRCQDRg+ZqbBt1xepvB9KVCFHRssJ8gGDzQfpsTCiR+yyy
X-Developer-Key: i=ms@dev.tdt.de; a=ed25519;
 pk=MAojd7D5IafMnqCYSFC7hY/u/jppX58CLIEhsEsSOYE=
X-purgate: clean
X-purgate-type: clean
X-purgate-ID: 151534::1796126495-CF680872-E975476E/0/0