From: netdev-bot+sashiko@kernel.org
To: 847807867@qq.com
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
Subject: Re: [PATCH] x25: defer socket cleanup on link termination to process context
Date: Mon, 23 Nov 2026 01:40:07 +0000 [thread overview]
Message-ID: <179539800759.3135.17245752044060918891@kernel.org> (raw)
In-Reply-To: <tencent_EC124B80BC53531B2EAB18DD04B37BAE7406@qq.com>
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
next prev parent reply other threads:[~2026-11-23 1:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 0:03 [syzbot] [x25?] inconsistent lock state in x25_kill_by_neigh (2) syzbot
2026-11-16 0:34 ` [PATCH] x25: defer socket cleanup on link termination to process context Shuai Liu
2026-11-18 18:35 ` netdev-bot+sashiko
2026-11-19 1:24 ` Shuai Liu
2026-11-23 1:40 ` netdev-bot+sashiko [this message]
2026-11-23 3:47 ` Shuai Liu
2026-11-23 3:48 ` [PATCH v3] " Shuai Liu
-- strict thread matches above, loose matches on Subject: below --
2026-10-01 15:01 [PATCH net] net/x25: don't call lock_sock() from softirq in x25_kill_by_neigh() Nguyen Ngoc Thang
2026-10-05 15:20 ` netdev-bot+sashiko
2026-11-23 7:57 ` Martin Schiller
2026-11-23 8:03 ` [PATCH] x25: defer socket cleanup on link termination to process context Martin Schiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179539800759.3135.17245752044060918891@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=847807867@qq.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-x25@vger.kernel.org \
--cc=ms@dev.tdt.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=syzbot+300375dfd44665f063a6@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox