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=1796129875; b=kgOZkf9xfIAKNmjoKX5tB2srpcfLZYOAhbv2skiDwVUzDzpSpnDoJrXh+43x482+3vXG a0+NouR6u5q46E5HFW6yIFr833Vkhg2wbtXypS6zds7MvDhpWkhDKEPi/CNS2RpTXDVU2 PZRC6uhc78vUa8tz77gyKkAUAdG79nT1C7UCD26s4+lLNMLooCuUA/rwO+Zn5wGnHMlkd M/HdBbb4OdxjuNuEb473t05fiijuChroFp4p4/rqYNc3L3owI3P7ZBk++QH4Ld2bIJlnf 3Ri+GjAQ+2zMDPNu2WDsAflraV5XImrxE31HsUPv8YxiNe9Q4Aho8WgpBwLa38ccYWw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796129875; 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=myj3b/bWHLsh5+DWIh/2IQ03XHqJ2RfvAgoEKEMnxg0=; b=TEXBI0lxdmG7GatFD2+MrOUkXsxM30UPxdzL+FEcnqcdUnYHQZidCOTczV3rik6xgl3v HYcF7a5Be6/88IMUovsK7cc8/D9kju+GBExn7qDNnNLChB6o0G/kkxSuxOsB0VyPbEiKx EQnA1Flk9AIJh8fUQNSTXQKlqIYLBgZHVsNNZ00ffMhJIYAiwXE7PCPp0rxb7rx6YdmsT fzi7dc02p3WdFTpvqT6PAP4chQFh88uQMLZH1J6Rch/faTEZbgTbTI7r4hF3qkOumosIR 7seE+T8FtvISHYAnSWabjtRDpeUH8/1fkGntYd+N8D+yAQr5CsuIocURiZU6G0NmeAA== 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=GaU13VDq; 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 3AAB3606A320; Tue, 1 Dec 2026 12:57:55 +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=GaU13VDq Received: by smtp.kernel.org (Postfix) with ESMTPSA id 202691F00893; Tue, 1 Dec 2026 12:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796129874; bh=myj3b/bWHLsh5+DWIh/2IQ03XHqJ2RfvAgoEKEMnxg0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=GaU13VDqupMlzG0nD++ukVrpF769UOClF+pHhTMHlEfBAYhMf/J1Pxa/RXsUXPc62 5QGAdcpcfW2TJ1hiHOBLv2YGszqPQTNS+gmjTFBVi/HQjB4ckhwcilPG83zUnVlu1R yrBfPUHAzQV0piH7bUNIaLe4VCgy+wlCPQjTZyZASrgV9M/qCF/WKqc55lV89GTs6B zL3OgTADNPmdJ7FvYhUrI23nqBKWcCPbnDhaKxurJT5deY0Rw/uUrcePx7RP4IyCzq LtK8q61JMUjbifBWXclorNUk1d8MKl9t5XEQl1sEkAwmFlu5N/5ejKwPe6Oz/eg3Iz rTnjZPKTx30qg== Subject: Re: [PATCH net v2 2/2] 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, syzbot+8328573e4d0514392471@syzkaller.appspotmail.com, edumazet@kernel.org, horms@kernel.org, linux-x25@vger.kernel.org, pabeni@redhat.com, davem@davemloft.net, kuba@kernel.org, andrew+netdev@lunn.ch, hdanton@sina.com, willemb@google.com, xie.he.0141@gmail.com, syzbot+059a2795ad4cff2a2695@syzkaller.appspotmail.com Date: Tue, 01 Dec 2026 12:57:53 +0000 Message-ID: <179612987367.3146.17593233623166891863@kernel.org> In-Reply-To: References: X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-x25@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 · 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_queue, a transmit FIFO with no length limit, and drains it in a loop with no quota. - [Low] The commit message gives the wrong reason why hdlc_x25 can transmit inline while lapbeth has to defer to NAPI. - [Low] The patch adds a new member to struct lapb_register_struct (schedule_tx) and a new exported entry point (lapb_transmit_pending()). - [Low] In net/lapb/lapb_iface.c, lapb_tx_unlock() is defined with `__releases(&lapb->lock)`. -- net: lapb: transmit frames outside the protocol lock LAPB now queues outgoing frames on a new per-instance tx_queue while lapb->lock is held, and hands them to the driver once the lock is dropped. lapbeth defers the drain to its NAPI poll through a new schedule_tx() callback, while hdlc_x25 drains right after the unlock. On NETDEV_GOING_DOWN the queue is flushed, and frames produced after that are dropped. > diff --git a/include/linux/lapb.h b/include/linux/lapb.h > index b5333f9413dca..06e050d9ace62 100644 > --- a/include/linux/lapb.h > +++ b/include/linux/lapb.h > @@ -36,6 +36,8 @@ struct lapb_register_struct { > void (*disconnect_indication)(struct net_device *dev, int reason); > int (*data_indication)(struct net_device *dev, struct sk_buff *skb); > void (*data_transmit)(struct net_device *dev, struct sk_buff *skb); > + /* If set, schedule lapb_transmit_pending() outside the device TX lock. */ > + void (*schedule_tx)(struct net_device *dev); > }; [Severity: Low] The commit message says: hdlc_x25 sends the frames right after the lock is dropped. lapbeth calls into LAPB with its TX lock and up_lock held, so it sets the new schedule_tx() callback and sends them from its NAPI poll instead. Is that the real difference between the two drivers? x25_xmit() in drivers/net/wan/hdlc_x25.c is the hdlc device's ndo_start_xmit, so it also runs under the netdev TX lock. It also calls into LAPB with up_lock held: drivers/net/wan/hdlc_x25.c:x25_xmit() { ... spin_lock_bh(&x25st->up_lock); ... result = lapb_data_request(dev, skb); if (result != LAPB_OK) dev_kfree_skb(skb); spin_unlock_bh(&x25st->up_lock); ... } That looks the same as lapbeth_xmit(). The difference seems to be the data_transmit callback. lapbeth_data_transmit() calls dev_queue_xmit() on the lower device, which can loop back into lapbeth_xmit() and LAPB. x25_data_transmit() hands the frame straight to the hardware driver: drivers/net/wan/hdlc_x25.c:x25_data_transmit() { ... if (dev_nit_active(dev)) dev_queue_xmit_nit(skb, dev); hdlc->xmit(skb, dev); /* Ignore return value :-( */ } The new comment on schedule_tx uses the same TX lock wording. Could the comment say instead that schedule_tx should be set when data_transmit() can re-enter the network stack or LAPB? Could the commit message be updated to match? > @@ -57,6 +59,7 @@ extern int lapb_getparms(struct net_device *dev, struct lapb_parms_struct *parms > extern int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms); > extern int lapb_connect_request(struct net_device *dev); > extern int lapb_disconnect_request(struct net_device *dev); > +void lapb_transmit_pending(struct net_device *dev); [Severity: Low] Should Documentation/networking/lapb-module.rst be updated as part of this patch? It lists the members of struct lapb_register_struct and every LAPB function and callback. It does not mention schedule_tx or lapb_transmit_pending(). It also still describes data_transmit as: This is called by the LAPB module when data is to be transmitted to the remote system by the device driver. With this patch, frames are queued on lapb->tx_queue and sent later. A driver that sets schedule_tx must later call lapb_transmit_pending() outside its TX lock. If it doesn't, the frames stay on tx_queue until another LAPB entry point drains them or lapb_unregister() purges them. Once NETDEV_GOING_DOWN sets tx_stopped, lapb_data_transmit() returns 0 and the frames never reach the driver. [ ... ] > diff --git a/include/net/lapb.h b/include/net/lapb.h > index 6c07420644e45..08cb5ae934398 100644 > --- a/include/net/lapb.h > +++ b/include/net/lapb.h [ ... ] > @@ -109,6 +114,7 @@ struct lapb_cb { > }; > > /* lapb_iface.c */ > +void lapb_tx_unlock(struct lapb_cb *lapb); [Severity: Low] Should this prototype also carry the __releases() annotation? The definition in net/lapb/lapb_iface.c has it: void lapb_tx_unlock(struct lapb_cb *lapb) __releases(&lapb->lock) net/lapb/lapb_timer.c only sees this prototype. lapb_t1timer_expiry() and lapb_t2timer_expiry() take the lock with spin_lock_bh(&lapb->lock), and now release it only through lapb_tx_unlock(). With CONFIG_WARN_CONTEXT_ANALYSIS and CONFIG_WARN_CONTEXT_ANALYSIS_ALL, clang context analysis checks call sites against the declaration it can see. Would it then report both timer callbacks as returning with lapb->lock still held? Other headers put the annotation on the prototype, for example mutex_unlock() in include/linux/mutex.h. [ ... ] > diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c > index 1af36fd50a6c4..7f17200c48b35 100644 > --- a/net/lapb/lapb_iface.c > +++ b/net/lapb/lapb_iface.c [ ... ] > @@ -282,6 +285,61 @@ int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms) > } > EXPORT_SYMBOL(lapb_setparms); > > +/* Preserve the TX nesting level if another caller sends the frame. */ > +#define LAPB_TX_DEPTH(skb) ((skb)->cb[0]) > + > +/* One caller drains the FIFO. Other producers leave their frames to it. */ > +static void lapb_xmit_queued(struct lapb_cb *lapb) > +{ > + struct sk_buff *skb; > + > + lockdep_assert_held(&lapb->lock); > + if (lapb->tx_running) > + return; > + > + WRITE_ONCE(lapb->tx_running, true); > + while ((skb = __skb_dequeue(&lapb->tx_queue))) { > + 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); > + for (i = 0; i < depth; i++) > + dev_xmit_recursion_dec(); > + spin_lock(&lapb->lock); > + } [Severity: Medium] Can this loop run without bound? It runs with BH disabled and has no quota or need_resched() check. Each time it drops lapb->lock, other contexts can add more frames to tx_queue: lapbeth_rcv()->lapb_data_received()->lapb_data_input()->... ->lapb_send_control()->lapb_data_transmit()->__skb_queue_tail() The t1/t2 timers and lapbeth_xmit()->lapb_data_request() add frames the same way. With schedule_tx set, these producers only queue the frame and call napi_schedule(). All of the dev_queue_xmit() work falls on this single drainer. lapb_data_transmit() also has no length cap or drop policy for tx_queue: __skb_queue_tail(&lapb->tx_queue, skb); return 1; For lapbeth, the drain runs from lapbeth_napi_poll() before the budget loop: lapb_transmit_pending(lapbeth->axdev); for (; processed < budget; ++processed) { so neither the NAPI budget nor the net_rx_action() time limit applies to it. A remote L2 peer can send ETH_P_DEC frames that each produce a response frame. For example, in state 0 LAPB answers every DISC with UA, and every SABM with DM or UA. If the producers keep up with the drainer, could one CPU stay in softirq (soft lockup, RCU stall) while tx_queue keeps growing? Before this patch, each producer called dev_queue_xmit() inline, and the lower device's qdisc limited the backlog. Should tx_queue have a cap, and should this loop stop after a budget and reschedule itself? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/tencent_BFB53B9AEE4AF90B99337798FB43DACAC506%40qq.com