From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796492357; b=FTi08KSioLaDvS98B5a8zrk7z/W+0neUvhms8eDi6anVEmxmVauZlb6tyBqAL4tEzDC2 mCIlfzk73m5w5iHdAhsw/HqhFWRth9Cr3LOFMKPOfRy8NqNtjcFhjNa/YSbbgDxTvZjk1 RhGIpDnug+XUnhXe8cq8qM/HOFAmj81ExG359Qq74n4vD2neOb6gpvSZfKGrYdn/Vnsn1 u1wcxrFhykNSAlRmFpJeA0grYwbuutTfEyMDWRJvCDyF0wHSVpxJQS5Dv7Xhls5iFXJRA bRZRRWcFUKJIG4Hhv/q/1XI9Lip4IrO7j9LymWqTJWtex1uU4ASi+lOTPrdiPyqhDuw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796492357; 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=5Lg7wDS26V58/9a4T5tThjWXrPYspii6On+rT+w3XIc=; b=B7sWRfKvBaOlF9r7zt+0hGWYTRkLueJj34SycZJNjs4uVK3qn6v+cbTotdiEzId9gHmf 7gX/rSOFsCIm6zh2iMlGlMy9evPEFQIfQMKABOz9rJeSO+pF/csnccyu/bfYG68bTLHm5 rlddMkAFfiDe14P0+erNKi1/WzSWbftbQNaGpDsHEVQeCNFPFPqgFnNuA0MFHr+SIIsOF L4rgwa8My9lPBCnfNVzBURwRrnbJ7QvdL01QPzUrbUJT4co2sZu/kOtLvveENfKlXnHFE eodZ/+jSBmSjH9SfrRQGUnlixvtrTFsDFhDP0mjWJKF4JCosT1nyb/7k6djQd5mKljw== 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=FO6vsCYo; arc=none smtp.remote-ip=100.103.45.18 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 77787606A33A; Sat, 5 Dec 2026 17:39:17 +0000 (UTC) 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=FO6vsCYo Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5566F1F0092B; Sat, 5 Dec 2026 17:39:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796492357; bh=5Lg7wDS26V58/9a4T5tThjWXrPYspii6On+rT+w3XIc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=FO6vsCYo7Cj8BtvnbS0f1UlYv0a3tjKcPZUOAWCy6aHbjb6QUmfEk1Za9GbedaP+0 eoh+JjPT7QHd91C2gBzdEug7PJ5Z2MWhhcH8nAaBKajAAVpU88fLJCvsW6OOyAK3re YtRYrhQUBZrd/aahj094CY04QX5pnIwWKdjnAplrfn9pqjT9T0EJB2r3R1tahGk2fc C0mqOiC9+OJyrtqlsAI75dQ1d6qvUWhPDRvG+UJHUiXMpQJlRNW1Ta9/VyglaONrN6 nwGm4q48trA7z9aU+5yrv+ff/I7aBaPBPTG4ngb5tM1wfd2qcbPZrTBq2Vm93iUI41 K4vGEXs8QkYNQ== Subject: Re: [PATCH net v3 3/3] net: lapb: transmit frames outside the protocol lock From: netdev-bot+sashiko@kernel.org To: SuperSkidder@qq.com Cc: ms@dev.tdt.de, netdev@vger.kernel.org, hdanton@sina.com, davem@davemloft.net, horms@kernel.org, xie.he.0141@gmail.com, andrew+netdev@lunn.ch, edumazet@kernel.org, corbet@lwn.net, willemb@google.com, syzbot+8328573e4d0514392471@syzkaller.appspotmail.com, linux-doc@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, linux-x25@vger.kernel.org, syzbot+059a2795ad4cff2a2695@syzkaller.appspotmail.com Date: Sat, 05 Dec 2026 17:39:15 +0000 Message-ID: <179649235593.3146.905729325799246245@kernel.org> In-Reply-To: <20261202-lapb-unlock-v3-v3-3-65b6ce65141b@qq.com> References: <20261202-lapb-unlock-v3-v3-3-65b6ce65141b@qq.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider. Critical: 0 · High: 0 (1) · Medium: 1 · Low: 3 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 adds `lapb->tx_running` as a home-made ownership lock around data_transmit(). - [Low] lapbeth_napi_poll() (drivers/net/wan/lapbether.c) now calls lapb_transmit_pending() on every poll, whatever the budget. - [Low] Documentation/networking/lapb-module.rst says each lapb_transmit_pending() call "sends at most 64 frames". - [Low] The newly added API documentation in Documentation/networking/lapb-module.rst does not match the real… Pre-existing issues: - [High] This problem wasn't introduced by this patch, but the new TX FIFO drain keeps it in place. -- net: lapb: transmit frames outside the protocol lock This patch stops LAPB from calling data_transmit() under lapb->lock. Frames now go on a per-instance FIFO, which is drained after the lock is dropped. lapbeth gets a new schedule_tx() callback and drains from its NAPI poll, while hdlc_x25 drains inline and falls back to a work item. Closes: https://syzkaller.appspot.com/bug?extid=059a2795ad4cff2a2695 Closes: https://syzkaller.appspot.com/bug?extid=8328573e4d0514392471 > diff --git a/Documentation/networking/lapb-module.rst b/Documentation/networking/lapb-module.rst > index ff586bc9f005b..f2047e30822d7 100644 > --- a/Documentation/networking/lapb-module.rst > +++ b/Documentation/networking/lapb-module.rst > @@ -47,6 +47,7 @@ of the LAPB module:: > void (*disconnect_indication)(int token, int reason); > int (*data_indication)(int token, struct sk_buff *skb); > void (*data_transmit)(int token, struct sk_buff *skb); > + void (*schedule_tx)(int token); > }; [Severity: Low] Do the new prototypes in lapb-module.rst match include/linux/lapb.h? The struct listing here gives schedule_tx an int token. The Callbacks section added further down has a different version: void (*schedule_tx)(void *token); and the new entry point is documented as: bool lapb_transmit_pending(void *token); The header actually declares: void (*schedule_tx)(struct net_device *dev); bool lapb_transmit_pending(struct net_device *dev); The two new doc prototypes for schedule_tx also disagree with each other (int vs void *). [ ... ] > diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c > index ab71afaaf8482..a438b85e27f13 100644 > --- a/drivers/net/wan/lapbether.c > +++ b/drivers/net/wan/lapbether.c > @@ -93,6 +93,10 @@ static int lapbeth_napi_poll(struct napi_struct *napi, int budget) > napi); > struct sk_buff *skb; > int processed = 0; > + bool tx_more; > + > + /* LAPB limits each call, so TX is not charged to the RX budget. */ > + tx_more = lapb_transmit_pending(lapbeth->axdev); [Severity: Low] Should this drain be skipped when budget is 0? netpoll polls with a zero budget: net/core/netpoll.c:poll_one_napi() { ... /* We explicitly pass the polling call a budget of 0 to * indicate that we are clearing the Tx path only. */ work = napi->poll(napi, 0); ... } Before this patch a budget-0 poll did nothing here, because the RX loop is bounded by budget. Now it starts new transmissions: __netpoll_send_skb() netpoll_poll_dev(lapbeth) poll_napi() poll_one_napi() lapbeth_napi_poll(napi, 0) lapb_transmit_pending() lapb_xmit_queued() lapbeth_data_transmit() dev_queue_xmit(ethdev) Each such poll can send up to 64 frames and takes lapb_list_lock and lapb->lock with the _bh variants, possibly with IRQs disabled. netpoll_poll_dev() only checks netif_local_xmit_active() for the lapbeth device, not for the ethdev that data_transmit targets. Documentation/networking/napi.rst says a budget of 0 means the core "tries to only process skb Tx completions". This also seems to go against the new rule in include/linux/lapb.h that lapb_transmit_pending() is called "without holding any lock its transmit path takes". netpoll on lapbeth was already unsafe before this patch, because lapbeth_xmit() takes spin_lock_bh(&lapbeth->up_lock). So this adds a second path into an existing problem rather than a new one. Would gating the drain on budget != 0 be enough here? [ ... ] > diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c > index 1af36fd50a6c4..a04fd11b0af73 100644 > --- a/net/lapb/lapb_iface.c > +++ b/net/lapb/lapb_iface.c [ ... ] > @@ -282,6 +297,71 @@ int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms) [ ... ] > +static bool lapb_xmit_queued(struct lapb_cb *lapb) > +{ > + int quota = LAPB_TX_QUOTA; > + struct sk_buff *skb; > + > + lockdep_assert_held(&lapb->lock); > + if (lapb->tx_running) > + return false; > + > + WRITE_ONCE(lapb->tx_running, true); > + while ((quota-- > 0 || lapb->tx_stopped) && > + (skb = __skb_dequeue(&lapb->tx_queue))) { [Severity: Low] Can a NAPI drainer go past the 64 frame limit here? lapb-module.rst says each lapb_transmit_pending() call "sends at most 64 frames", and lapbeth_napi_poll() relies on that: /* LAPB limits each call, so TX is not charged to the RX budget. */ Suppose lapbeth's NAPI poll is inside data_transmit() with lapb->lock dropped while lapb_device_event(NETDEV_GOING_DOWN) runs: lapb->tx_stopped = true; quiesce = true; The notifier's own lapb_xmit_queued() returns at once because tx_running is set. When the NAPI drainer retakes the lock, the quota check is bypassed for the rest of the loop. That single poll then empties the whole FIFO, up to LAPB_TX_QUEUE_MAX frames. This is bounded and only happens at shutdown, but in that case neither the documented limit nor the lapbeth comment is accurate. > + int depth = LAPB_TX_DEPTH(skb) - dev_recursion_level(); > + int i; > + > + spin_unlock(&lapb->lock); > + for (i = 0; i < depth; i++) > + dev_xmit_recursion_inc(); > + lapb->callbacks->data_transmit(lapb->dev, skb); [Severity: High] This isn't a bug introduced by this patch, but the new drain paths leave it in place. For hdlc_x25, data_transmit is x25_data_transmit(), and it calls the hardware xmit directly: drivers/net/wan/hdlc_x25.c:x25_data_transmit() { ... hdlc->xmit(skb, dev); /* Ignore return value :-( */ } This skips the netdev TX queue and never checks netif_queue_stopped(). The SCA drivers stop the queue when the ring is nearly full. They expect not to be called again before TX-done: drivers/net/wan/hd64572.c:sca_xmit() { ... desc = desc_address(port, port->txin + 1, 1); BUG_ON(readb(&desc->stat)); /* previous xmit should stop queue */ ... } hd64570.c has the same BUG_ON. When its ring is full, wanxl_xmit() returns NETDEV_TX_BUSY without consuming the skb. The return value is ignored, so the skb leaks and the frame is lost. LAPB can send far more frames back to back than these rings hold: - x25_ioctl() allows modulo 128 with a window up to 127. - lapb_kick() sends a full window at once. - c101 and wanxl have only 10 TX descriptors. - On a stalled line, T1 retransmissions through lapb_requeue_frames() and lapb_kick() add more frames. With this patch, a drain sends 64 frames and then reschedules tx_work right away, and the GOING_DOWN flush ignores the quota for up to 256 frames: lapb_data_request() / lapb_t1timer_expiry() lapb_kick() lapb_tx_unlock() lapb_xmit_queued() x25_data_transmit() hdlc->xmit() == sca_xmit() BUG_ON() after a previous netif_stop_queue() The patch adds new deferred drain points (lapb_tx_work() and the GOING_DOWN flush). Could they apply some backpressure, such as stopping while the device's TX queue is stopped, instead of handing every queued frame to hdlc->xmit()? > + for (i = 0; i < depth; i++) > + dev_xmit_recursion_dec(); > + spin_lock(&lapb->lock); > + } > + WRITE_ONCE(lapb->tx_running, false); > + if (lapb->tx_stopped) > + wake_up_all(&lapb->tx_wait); > + return !skb_queue_empty(&lapb->tx_queue); > +} [Severity: Medium] Is tx_running effectively acting as a lock here? It is set on entry, lapb->lock is dropped around data_transmit(), and it is cleared on exit. Any other drainer that sees it set returns at once. That flag is now the only thing serializing data_transmit() callers. It protects the unlocked ndev->stats.tx_packets++ in lapbeth_data_transmit() and the direct hdlc->xmit() calls. lapb_device_event() then sleeps on it uninterruptibly with RTNL held: wait_event(lapb->tx_wait, !READ_ONCE(lapb->tx_running)); Lockdep can't see a bool plus a waitqueue. The dependency from LAPB TX serialization to the locks taken under dev_queue_xmit() or hdlc->xmit() still exists, but lockdep no longer tracks it. A future cycle through it would show up as a hung task instead of a lockdep report. The waiter's check is also a lockless READ_ONCE() with no acquire ordering. Nothing orders it against the drainer's last data_transmit() side effects before the notifier moves on to ndo_stop. I couldn't find a transmit path that takes RTNL today, so this doesn't look like a concrete deadlock yet. Would a real primitive keep it visible to lockdep? For example, a dedicated per-lapb TX lock, or test_and_set_bit()/wait_on_bit() with a lockdep_map. [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-lapb-unlock-v3-v3-0-65b6ce65141b%40qq.com