From: willemb@google.com
To: Yu Gao <SuperSkidder@qq.com>, Martin Schiller <ms@dev.tdt.de>,
netdev@vger.kernel.org
Cc: linux-x25@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Xie He <xie.he.0141@gmail.com>,
Hillf Danton <hdanton@sina.com>,
syzbot+059a2795ad4cff2a2695@syzkaller.appspotmail.com,
syzbot+8328573e4d0514392471@syzkaller.appspotmail.com,
Yu Gao <SuperSkidder@qq.com>
Subject: Re: [PATCH net 0/2] net: lapbether: fix lock cycles reported by syzbot
Date: Sun, 29 Nov 2026 22:21:06 -0500 [thread overview]
Message-ID: <willemb.1ecc71273e778@google.com> (raw)
In-Reply-To: <tencent_AD34C10B65771ADD86725F3221EE31778507@qq.com>
Yu Gao wrote:
> LAPB transmits frames through lapbeth_data_transmit() with lapb->lock
> held, and lapb_unregister() takes lapb->lock with lapb_list_lock held
> for writing. When the Ethernet device under a lapbeth device is a
> tunnel (gretap or vxlan in the syzbot reproducers) whose packets are
> routed through a lapbeth device, a frame sent by LAPB comes back into
> lapbeth_xmit(), which runs under the TX lock of that device and takes
> up_lock before calling into LAPB. LAPB then takes lapb_list_lock to
> look up the device, which closes a cycle. lapbeth_rcv() also calls into
> LAPB with up_lock held.
> Patch 1 stops holding up_lock across calls into LAPB and removes it.
> Closing the device now clears "up" and waits for lapbeth_xmit() and
> lapbeth_rcv() with synchronize_net() before lapb_unregister(). This
> fixes the lapb_data_received report.
> Patch 2 makes lapbeth an LLTX device, so that the core no longer takes
> the TX lock around lapbeth_xmit(). With patch 1 alone, the
> lapb_connect_request reproducer still reports a cycle through
> _xmit_X25. Patch 2 removes it.
> Testing was done on QEMU with the syzbot config, with lockdep and
> KASAN enabled:
> - On an unpatched kernel, both C reproducers report a cycle within 15
> seconds. With both patches, neither reports anything in runs of 400
> and 600 seconds each.
> - A functional test runs one lapbeth device over a veth pair, with the
> other end driven as a LAPB DCE from user space. It covers link setup
> and teardown from either side, about 100 frames from the peer and 370
> frames to the peer through lapbeth_xmit(), and closing the device
> mid-transfer. All frames arrive in order, and the output is identical
> with and without the series.
> - 300 up/down cycles of a lapbeth device while frames are sent in both
> directions produce no warnings.
> - A lapbeth device on a gretap tunnel whose remote address is routed
> back through the same lapbeth device: on an unpatched kernel, a SABM
> received through the tunnel deadlocks on up_lock when the UA comes
> back into lapbeth_xmit(). With the series, the looped IP packet is
> dropped, in three out of three runs. With an MPLS route instead
> (first byte 0x00), the T1 timer path deadlocks on lapb->lock with and
> without the series.
This points to the actual root cause in net/lapb/: lapb_data_transmit()
invokes
lapbeth_data_transmit() -> dev_queue_xmit() synchronously while holding
&lapb->lock, and lapb_unregister() takes &lapb->lock (and even calls
usleep_range()) while holding write_lock_bh(&lapb_list_lock).
Working around the cycle purely in lapbether only hides the syzbot
IPv4/IPv6
reproducers because IPv4/IPv6 headers start with 0x45/0x60 and get
dropped in
lapbeth_xmit() before calling into LAPB. Any tunnel path whose outer
packet
starts with 0x00/0x01/0x02 (such as the MPLS route tested here, or a TC
rewrite) still re-enters LAPB from under &lapb->lock:
- On the same lapbeth device, it immediately self-deadlocks on
&lapb->lock
(and Patch 2 turns the TX path into the same hard deadlock too).
- Across two lapbeth devices (lapb0 -> tunnel -> lapb1),
lapbeth_xmit(lapb1)
takes read_lock_bh(&lapb_list_lock) and spin_lock_bh(&lapb1->lock)
while
holding &lapb0->lock, recreating both the lapb_list_lock <->
&lapb->lock
deadlock (vs lapb_unregister()) and &lapb->lock recursive/AB-BA
locking.
Decoupling this at the LAPB layer instead — releasing lapb_list_lock
right
after unlinking in lapb_unregister() and not calling
callbacks->data_transmit()
under &lapb->lock (e.g. deferring transmit outside &lapb->lock) — fixes
the
root lock inversion across TX, RX, and timers without regressing TX loop
detection.
> No end-to-end test with X.25 sockets was done.
> Yu Gao (2):
> net: lapbether: don't hold up_lock while calling into LAPB
> net: lapbether: use lockless TX
> drivers/net/wan/lapbether.c | 42 ++++++++++++++++---------------------
> 1 file changed, 18 insertions(+), 24 deletions(-)
> --
> 2.54.0 (Apple Git-157)
next prev parent reply other threads:[~2026-11-30 3:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 4:59 [PATCH net 0/2] net: lapbether: fix lock cycles reported by syzbot Yu Gao
2026-11-25 8:52 ` Martin Schiller
2026-11-30 3:21 ` willemb [this message]
2026-11-30 7:01 ` Martin Schiller
2026-11-30 7:39 ` SuperSkidder
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=willemb.1ecc71273e778@google.com \
--to=willemb@google.com \
--cc=SuperSkidder@qq.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hdanton@sina.com \
--cc=kuba@kernel.org \
--cc=linux-x25@vger.kernel.org \
--cc=ms@dev.tdt.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=syzbot+059a2795ad4cff2a2695@syzkaller.appspotmail.com \
--cc=syzbot+8328573e4d0514392471@syzkaller.appspotmail.com \
--cc=xie.he.0141@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.