mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Martin Schiller <ms@dev.tdt.de>
To: Martin Schiller <ms@dev.tdt.de>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>, Lin Ma <linma@zju.edu.cn>,
	Duoming Zhou <duoming@zju.edu.cn>,
	Xiyu Yang <xiyuyang19@fudan.edu.cn>,
	Xin Tan <tanxin.ctf@gmail.com>
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
Subject: [PATCH net v2 0/2] net/x25: don't call lock_sock() from softirq in x25_kill_by_neigh()
Date: Fri, 27 Nov 2026 07:28:04 +0100 (CET)	[thread overview]
Message-ID: <20261127-x25-kill-by-neigh-v2-0-c7cdcc9f1320@dev.tdt.de> (raw)

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 v2 of 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. v2 addresses the AI review of v1 [2]: 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.

Patch 2 fixes a pre-existing NULL pointer dereference in x25_sendmsg(),
x25_output() and x25_recvmsg() after they retake the socket lock. The
same review pointed out the first two, Krystian Kaniewski found the
x25_recvmsg() case. It is independent of patch 1.

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    v2    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. v1 was also tested by Thang with the PREEMPT_RT config and the
C reproducer of [6]; the changes in v2 add no locking.

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/6aa7e6d0.4c28b7d0.c1bba.001c.GAE@google.com/

---
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   | 76 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 net/x25/x25_out.c  |  9 ++++++-
 net/x25/x25_subr.c |  4 +++
 4 files changed, 82 insertions(+), 8 deletions(-)
---
base-commit: c5de2ce2fccdb7d3b48946179634eaa3d7ce2e7e
change-id: 20261124-x25-kill-by-neigh-2b70f6d19961

Best regards,
-- 
Martin Schiller <ms@dev.tdt.de>


             reply	other threads:[~2026-11-27  6:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  6:28 Martin Schiller [this message]
2026-11-27  6:28 ` [PATCH net v2 1/2] " Martin Schiller
2026-11-27  6:28 ` [PATCH net v2 2/2] net/x25: re-check x25->neighbour after re-acquiring the socket lock Martin Schiller
2026-11-27  6:33 ` [PATCH net v2 0/2] net/x25: don't call lock_sock() from softirq in x25_kill_by_neigh() netdev-bot+sinfo
2026-11-27  6:43   ` Martin Schiller
2026-11-27 11:48 ` Martin Schiller
2026-11-27 13:30 ` Krystian Kaniewski

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=20261127-x25-kill-by-neigh-v2-0-c7cdcc9f1320@dev.tdt.de \
    --to=ms@dev.tdt.de \
    --cc=847807867@qq.com \
    --cc=davem@davemloft.net \
    --cc=duoming@zju.edu.cn \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=krystianmkaniewski@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linma@zju.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-x25@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ngocthang2710.1999@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=syzbot+300375dfd44665f063a6@syzkaller.appspotmail.com \
    --cc=syzbot+9faa82ae2e94c5c7d2ef@syzkaller.appspotmail.com \
    --cc=tanxin.ctf@gmail.com \
    --cc=willemb@google.com \
    --cc=xiyuyang19@fudan.edu.cn \
    /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

all inboxes | Powered by JetHome®