* [PATCH net 0/2] net: lapbether: fix lock cycles reported by syzbot
@ 2026-11-25 4:59 Yu Gao
2026-11-25 8:52 ` Martin Schiller
2026-11-30 3:21 ` willemb
0 siblings, 2 replies; 3+ messages in thread
From: Yu Gao @ 2026-11-25 4:59 UTC (permalink / raw)
To: Martin Schiller, netdev
Cc: linux-x25, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Xie He, Hillf Danton,
syzbot+059a2795ad4cff2a2695, syzbot+8328573e4d0514392471, Yu Gao
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.
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)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net 0/2] net: lapbether: fix lock cycles reported by syzbot
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
1 sibling, 0 replies; 3+ messages in thread
From: Martin Schiller @ 2026-11-25 8:52 UTC (permalink / raw)
To: Yu Gao
Cc: netdev, linux-x25, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Xie He, Hillf Danton,
syzbot+059a2795ad4cff2a2695, syzbot+8328573e4d0514392471
On Wed, 25 Nov 2026 05:59:07 +0100, Yu Gao wrote:
> Patch 1 stops holding up_lock across calls into LAPB and removes it.
Thanks, this is a small and clean way to break both cycles. Both entry
points into LAPB run in an RCU read-side critical section, so
synchronize_net() covers them, and LAPB serializes the rest under
lapb->lock, so lapbeth_xmit() doesn't need the TX lock.
> No end-to-end test with X.25 sockets was done.
With the series applied on top of the pending x25_kill_by_neigh() fix,
an X.25 end-to-end test over two lapbether devices on a veth pair
passes with lockdep and without warnings: calls over the link, a LAPB
disconnect and a restart while calls are up, and
"ip link set lapb0 down".
For the series:
Acked-by: Martin Schiller <ms@dev.tdt.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net 0/2] net: lapbether: fix lock cycles reported by syzbot
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
1 sibling, 0 replies; 3+ messages in thread
From: willemb @ 2026-11-30 3:21 UTC (permalink / raw)
To: Yu Gao, Martin Schiller, netdev
Cc: linux-x25, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Xie He, Hillf Danton,
syzbot+059a2795ad4cff2a2695, syzbot+8328573e4d0514392471, Yu Gao
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)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-30 3:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox