🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20639

Re: [PATCH] x25: defer socket cleanup on link termination to process context

#20639
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 01:40
185 lines
14093 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch makes clearing of existing virtual calls
  asynchronous.
- [Low] x25_device_event() (net/x25/af_x25.c) calls x25_link_terminated()
  from two process-context notifier events, and the patch treats them…

--

x25: defer socket cleanup on link termination to process context

This patch moves x25_kill_by_neigh() out of softirq context and into a
per-neighbour work item on a new dedicated x25 workqueue, which avoids
calling lock_sock() from softirq. The work holds references on the
neighbour and its net_device, and NETDEV_DOWN flushes the work.

Closes: https://syzkaller.appspot.com/bug?extid=300375dfd44665f063a6

> diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
> index f45c9ec7d2c68..a1a8bc203a24f 100644
> --- a/net/x25/af_x25.c
> +++ b/net/x25/af_x25.c
> @@ -222,6 +222,7 @@ static int x25_device_event(struct notifier_block *this, unsigned long event,
>  			nb = x25_get_neigh(dev);
>  			if (nb) {
>  				x25_link_terminated(nb);
> +				flush_work(&nb->kill_work);
>  				x25_neigh_put(nb);
>  			}
>  			x25_route_device_down(dev);

[Severity: Low]
NETDEV_DOWN now flushes kill_work. Should the NETDEV_CHANGE case in
x25_device_event() flush it as well?

net/x25/af_x25.c:x25_device_event() {
    ...
		case NETDEV_CHANGE:
			if (!netif_carrier_ok(dev)) {
				nb = x25_get_neigh(dev);
				if (nb) {
					x25_link_terminated(nb);
					x25_neigh_put(nb);
				}
			}
			break;
    ...
}

Both cases run in process context under RTNL. Before this patch, both
cleared the sockets synchronously.

After carrier loss, the sockets now stay attached to nb with
nb->state == X25_LINK_STATE_0 until the worker runs. During that window
they can still send through x25_transmit_link(), which would queue the
frame and call x25_establish_link().

Only the softirq callers seem to need the deferral. The process-context
callers could keep the old behaviour with a flush, or by calling
x25_kill_by_neigh() directly.

[ ... ]

> diff --git a/net/x25/x25_link.c b/net/x25/x25_link.c
> index d1e8cd81c2143..424044c1cf974 100644
> --- a/net/x25/x25_link.c
> +++ b/net/x25/x25_link.c

[ ... ]

> +static void x25_defer_kill_by_neigh(struct x25_neigh *nb)
> +{
> +	x25_neigh_hold(nb);
> +	dev_hold(nb->dev);
> +	if (!queue_work(x25_wq, &nb->kill_work)) {
> +		dev_put(nb->dev);
> +		x25_neigh_put(nb);
> +	}
> +}
> +
>  /*
>   *	This handles all restart and diagnostic frames.
>   */
> @@ -82,7 +103,7 @@ void x25_link_control(struct sk_buff *skb, struct x25_neigh *nb,
>  			break;
>  		case X25_LINK_STATE_3:
>  			/* clear existing virtual calls */
> -			x25_kill_by_neigh(nb);
> +			x25_defer_kill_by_neigh(nb);
>  
>  			x25_transmit_restart_confirmation(nb);
>  			break;

[Severity: Medium]
With this change, does the restart/terminate sequence continue while the
old virtual calls are still bound to nb?

x25_defer_kill_by_neigh() only queues the work and returns. In
x25_link_control(), the restart confirmation (or the restart request,
the move to X25_LINK_STATE_2, and T20 in the RESTART_CONFIRMATION case)
goes out first. nb->queue is also drained in STATE_3 at the end of the
function.

The old sockets are still on x25_list at that point, with
x25->neighbour == nb and their old LCIs. The same applies to
x25_link_terminated(), which sets STATE_0 but leaves the sockets
connected. Neither the softirq X25_IFACE_DISCONNECT path nor
NETDEV_CHANGE flushes the work.

Until the worker runs, a few things look possible.

If the peer reuses an LCI after the restart, x25_receive_data() still
matches the stale socket:

net/x25/x25_dev.c:x25_receive_data() {
    ...
	if ((sk = x25_find_socket(lci, nb)) != NULL) {
		...
		queued = x25_process_rx_frame(sk, skb);
		...
	}

	if (frametype == X25_CALL_REQUEST)
		return x25_rx_call_request(skb, nb, lci);
    ...
}

So could a new CALL_REQUEST on a reused LCI be handed to the old socket
instead of reaching x25_rx_call_request()?

A stale socket can also still transmit via x25_transmit_link(). In
STATE_0 that queues the frame and calls x25_establish_link(), which
brings the link back up for a dead call. In STATE_1/2 the frame is
queued and flushed later onto the restarted link.

When x25_kill_by_neigh_work()->x25_kill_by_neigh() finally runs, it
disconnects every socket whose neighbour == nb at that moment. That
includes calls set up after the triggering event, such as sockets from
x25_rx_call_request() or outgoing calls from x25_connect():

	x25->neighbour = x25_get_neigh(rt->dev);

Can valid new calls get torn down with ENETUNREACH this way? The same
question applies to forwards that x25_clear_forward_by_dev() removes
after being created post-event.

The comments "clear existing virtual calls" and "Out of order: clear
existing virtual calls (X.25 03/93 4.6.3)" also no longer match what
happens synchronously.

One option might be to detach the sockets synchronously in softirq (for
example, mark them dead or clear lci/neighbour under x25_list_lock or
bh_lock_sock()) and defer only the part that sleeps.

> @@ -97,7 +118,7 @@ void x25_link_control(struct sk_buff *skb, struct x25_neigh *nb,
>  			break;
>  		case X25_LINK_STATE_3:
>  			/* clear existing virtual calls */
> -			x25_kill_by_neigh(nb);
> +			x25_defer_kill_by_neigh(nb);
>  
>  			x25_transmit_restart_request(nb);
>  			nb->state = X25_LINK_STATE_2;
> @@ -254,7 +275,7 @@ void x25_link_terminated(struct x25_neigh *nb)
>  	x25_stop_t20timer(nb);
>  
>  	/* Out of order: clear existing virtual calls (X.25 03/93 4.6.3) */
> -	x25_kill_by_neigh(nb);
> +	x25_defer_kill_by_neigh(nb);
>  }

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/tencent_EC124B80BC53531B2EAB18DD04B37BAE7406%40qq.com
Technical Details
Message-ID: <179539800759.3135.17245752044060918891@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368942-linux-kernel-netdev=dewy.ru
References: <tencent_EC124B80BC53531B2EAB18DD04B37BAE7406@qq.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368942-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH] x25: defer socket cleanup on link termination to process context
Date: Mon, 23 Nov 2026 01:40:07 +0000
Organization: Usenet Network
Message-ID: <179539800759.3135.17245752044060918891@kernel.org>
References: <tencent_EC124B80BC53531B2EAB18DD04B37BAE7406@qq.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="3764794"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Q1Li8gkTMaMYojbGidkcSVQzf7c= sha256:DPIo/6E5kNaUSzduFcf1LLbbMrXT6mDrikE9Ynatln4= sha1:cXaotrzBEtY2MtWRAFPTnYUslTg= sha256:98mf1WTC7apZ2t37KxBcHa/7aAXaLVjnyVa1DxCbIxs=
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 1C62E125D8B; Mon, 23 Nov 2026 04:40:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=kernel.org
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 H0_7dlv7GpF4; Mon, 23 Nov 2026 04:40:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-368942-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id A71F0125D87; Mon, 23 Nov 2026 04:40:18 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 00E2028488; Mon, 23 Nov 2026 01:40:13 +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=1795398010; b=D0KSdSwb/6b5OjkVp8LvsU8BoP2mqFIw4Xv2It7suizrpeFQNjUdeGDLhKzEnf8/yYtK 7uzHr9T7wSJ5O8YdPr8WqBnIPBgSDjOf+G52xMDjBEWFVMla5AlwU2YBskbxLOWB+7Hyc QXb0EX2U45hfyVoiqF0HckqekmQd7XxtE528hxkY9DdixML64txiEkK4UrC82I8oqAXBd oC9eu+wXGHMjRL7Gu3mfGV6DRScPDpK7oq2mSXZTBPwXTsvLdoPFctxkN/doJppPqmCyP ToICsvvaeGZzDyig/iH+6kBtE32ini7vyEoC0e4zg1H6xlAzCZ85V44fyylTzC0gjPA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795398010; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=ceIIcc4zK+CPfUbBfPOZqR1EDh72ggw2yVO7k0cL/kQ=; b=QRdVZT22PQ9jsd4uk5uhu8XYbl3vzzaS5ZEpSHijeo/HOYYSLDW05WF1i6kS9LKXGjD1 uFPVPy4UkWtqitds1fN5380mQLHmH3AkxKPydz1EhQ3MsDXWkZhIHGd00VCigbBLwFGr8 mthV2ZKhILvvW05TUWJpjmryRSTo/oNp42xKZRPluMkYNJl0ArbNxre5tskVm0aVrcziD BXmFdzwOHbk2dM5ptHzA+TIVluPjl5YpnkH0w+WZ+nQF9GYSy13RPL8W2FCcQe5i4WXL4 ZdQmjnMwsgPWjz3dNXMBYX5OaEjyEvHKDkWUrm7wD5Q09xvxSHCfcdhL1ykIxSJneNw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WsKWYh4s; 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 02A92606A336; Mon, 23 Nov 2026 01:40:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WsKWYh4s
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795398009; b=CnQO6dXK4dl96YGywT/A5+JHb+NveRqgopwVWyQOnaMYgQmHiqAUPZd2uPwQWj2CiVoL HirLGrMEhl2dm79jIY+O891+3fiKXWqLhTkefgTeulduoxtHZJ75h5Icup625zXwcPUbz RXL4skZzqIR6aWNMzsSCM4YJKNAvHS/Fdb9oeGnZcSnAk0vQ0mD4x+xX8YKbiFD+MRR3r RWfhHyCMN3dUgatJB4FiBArONSGshRs5y4USzRBqv/qkaO0KEfhuvWRE0Qze1TFLkDgs+ N+MLFwXyrO0+Z2FkRYYb0p2EfNnH9F1xI4ycmp0kXVbyQAkyJoDca4IJFfyYyps7cgg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795398009; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=ceIIcc4zK+CPfUbBfPOZqR1EDh72ggw2yVO7k0cL/kQ=; b=eDWxxkqAiujz9RkTLw9/gO8On8/o1ApMYjA2+hLc+PaRmNf2BLO60SwOV0BfQXZ9HE3O bJ4kN8qPwcJbGTfQhMuB9ItQv1sB/RS1xUmZ2LECm4kurpqweApz4B00jM8Whq+ujG2OD t2MR4W0okAqsdCV5HCsSp0ub19ZFL5XJPNxHHC0Vfm4GRG9eVK/OJIr7cDvsYrMd//10u omEeb6iuAaRdW7CbdJOPVWolXgrNHm3JdKJw8v2scTCFSUeu9ODIYQWFqwddlYvEleab7 y0fNNaxd4pxePSJH1Y1FdJikbOWdWXiKxUfQbmugfmTgAg9oJxUcPT3dJwnFQwxpckQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WsKWYh4s; arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DBF5606A31A; Mon, 23 Nov 2026 01:40:08 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F4001F000CA; Mon, 23 Nov 2026 01:40:08 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795398008; bh=ceIIcc4zK+CPfUbBfPOZqR1EDh72ggw2yVO7k0cL/kQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=WsKWYh4sY2Lb7noH2Cjog3vul3I/aqK4L4wpahyxWlXhe0ytZeCFa6h9ZbLKFc9X/ cuJyEkerxsU/paW8mFIT8I9hjeaH+tEU3rnHKeMSHXCJj5qOib9s4UNc3Sqs2b+snt lVVOeiSrfuwmi9lX7jbRqKIWTg86kmHczAGd6YagP6X/7qfqJUFB2VB6YCDAq+uhi/ +oTDFGEVPzPC5V1a/q4UUqtk2DT+oprxjxD8sSKxBYvX0KAyw7VvJU7QTBTPD2kw3z lWSUZ/GtPcPPzSaKuij8Vy74fwS4RqvE8xCPQg9pf6B/ggaKvBScWh8yzxKX2ohowY 7+nHJUcXHtE5A==
X-Cc: ms@dev.tdt.de, linux-x25@vger.kernel.org, netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, edumazet@kernel.org, pabeni@redhat.com, horms@kernel.org, syzbot+300375dfd44665f063a6@syzkaller.appspotmail.com, linux-kernel@vger.kernel.org, netdev-bot+sashiko@kernel.org, stable@vger.kernel.org
X-In-Reply-To: <tencent_EC124B80BC53531B2EAB18DD04B37BAE7406@qq.com>
X-sashiko-severity: Medium
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