Linux Documentation
 help / color / mirror / Atom feed
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
Subject: Re: [PATCH net v3 2/3] net: lapbether: bound the receive queue
Date: Sat, 05 Dec 2026 17:39:14 +0000	[thread overview]
Message-ID: <179649235448.3146.5216638636094775268@kernel.org> (raw)
In-Reply-To: <20261202-lapb-unlock-v3-v3-2-65b6ce65141b@qq.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 0

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 new limit check in lapbeth_rcv()
  (drivers/net/wan/lapbether.c) runs before lapb_data_received() and…
- [Medium] The patch is titled 'bound the receive queue', but the bound
  only applies to indications that start in lapbeth_rcv().

--

net: lapbether: bound the receive queue

This patch drops received frames in lapbeth_rcv() once lapbeth->rx_queue
reaches netdev_max_backlog, so a peer cannot grow the queue without limit.
It also purges rx_queue in lapbeth_close(), so stale entries don't count
against the limit after the device is reopened.

> diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
> index c3630a82913bf..ab71afaaf8482 100644
> --- a/drivers/net/wan/lapbether.c
> +++ b/drivers/net/wan/lapbether.c

[ ... ]

> @@ -132,6 +133,16 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev,
>  	if (!lapbeth->up)
>  		goto drop_unlock;
>  
> +	/* A frame dropped before LAPB sees it is like one lost on the wire,
> +	 * and the peer retransmits it. This keeps a peer from growing
> +	 * rx_queue without limit.
> +	 */
> +	if (skb_queue_len_lockless(&lapbeth->rx_queue) >=
> +	    READ_ONCE(net_hotdata.max_backlog)) {
> +		DEV_STATS_INC(lapbeth->axdev, rx_dropped);
> +		goto drop_unlock;
> +	}

[Severity: Medium]

Does this comment hold for every frame type dropped here? The check runs
before lapb_data_received(), so while rx_queue is full LAPB sees no
incoming frames at all. That includes I-frames carrying N(R) acks,
RR/RNR/REJ, UA, DM and FRMR responses, and SABM/DISC.

The peer only retransmits its own I-frames and commands. It won't resend
acks or responses that we dropped. Only our local T1 recovers those, and
each T1 expiry in state 3 increments n2count:

net/lapb/lapb_timer.c:lapb_t1timer_expiry() {
    ...
		case LAPB_STATE_3:
			if (lapb->n2count == lapb->n2) {
				lapb_clear_queues(lapb);
				lapb->state = LAPB_STATE_0;
				lapb_stop_t2timer(lapb);
				lapb_disconnect_indication(lapb, LAPB_TIMEDOUT);
    ...
}

Because the peer's acks are thrown away, the local TX window also stalls.

Under sustained congestion, can this reset the local link and tear down
every X.25 call?

The commit message also describes this as "the limit netif_rx() applied
before the commit below". Before 514e1150da9c, that limit was applied
after LAPB had parsed the frame. lapbeth_data_indication() returned the
NET_RX_DROP verdict, and lapb_state3_machine() had already processed N(R)
by then. It only skipped the V(R) advance:

net/lapb/lapb_in.c:lapb_state3_machine() {
    ...
		if (lapb->condition & LAPB_PEER_RX_BUSY_CONDITION)
			lapb_frames_acked(lapb, frame->nr);
		else
			lapb_check_iframes_acked(lapb, frame->nr);

		if (frame->ns == lapb->vr) {
			int cn;
			cn = lapb_data_indication(lapb, skb);
			queued = 1;
			...
			if (cn == NET_RX_DROP) {
				pr_debug("rx congestion\n");
				break;
			}
    ...
}

With that mechanism only the inbound I-frame is deferred, and the peer
retransmits it. That is the behaviour the new comment and the commit
message describe.

Would it work better to apply the limit in lapbeth_data_indication() and
return NET_RX_DROP there, so LAPB's existing congestion handling is used?
If not, could the comment and commit message be changed to describe what
this check actually does?

The later patches in this series don't touch lapbeth_rcv(), so this stays
the same at the end of the series.

[Severity: Medium]

Does this bound cover every producer of rx_queue? lapbeth_connected() and
lapbeth_disconnected() still queue on rx_queue with no length check:

drivers/net/wan/lapbether.c:lapbeth_connected() {
    ...
	skb->protocol = x25_type_trans(skb, dev);

	skb_queue_tail(&lapbeth->rx_queue, skb);
	napi_schedule(&lapbeth->napi);
}

lapbeth_xmit() reaches both of them without going through lapbeth_rcv():

drivers/net/wan/lapbether.c:lapbeth_xmit() {
    ...
	case X25_IFACE_CONNECT:
		err = lapb_connect_request(dev);
		if (err == LAPB_CONNECTED)
			lapbeth_connected(dev, LAPB_OK);
    ...
	case X25_IFACE_DISCONNECT:
		err = lapb_disconnect_request(dev);
		if (err == LAPB_NOTCONNECTED)
			lapbeth_disconnected(dev, LAPB_OK);
    ...
}

lapb_connect_request() returns LAPB_CONNECTED on every call while LAPB is
in state 3 or 4. A disconnect request returns LAPB_NOTCONNECTED while LAPB
is in state 0.

So a sender with CAP_NET_RAW and a packet socket on the lapb device can
queue one indication per 1-byte frame it transmits, from several CPUs at
once. Meanwhile lapbeth_napi_poll() drains at most 16 skbs per poll, on
one CPU.

Before 514e1150da9c these indications went through netif_rx() and were
capped by netdev_max_backlog. The rest of the series doesn't change
lapbeth_xmit(), lapbeth_connected() or lapbeth_disconnected().

Would moving the check to the enqueue point, in the indication callbacks,
bound every producer?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-lapb-unlock-v3-v3-0-65b6ce65141b%40qq.com

  reply	other threads:[~2026-12-05 17:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 17:18 [PATCH net v3 0/3] net: lapb: don't call the driver with LAPB locks held Yu Gao via B4 Relay
2026-12-01 17:18 ` [PATCH net v3 1/3] net: lapb: drop lapb_list_lock before waiting for users Yu Gao via B4 Relay
2026-12-01 17:18 ` [PATCH net v3 2/3] net: lapbether: bound the receive queue Yu Gao via B4 Relay
2026-12-05 17:39   ` netdev-bot+sashiko [this message]
2026-12-01 17:18 ` [PATCH net v3 3/3] net: lapb: transmit frames outside the protocol lock Yu Gao via B4 Relay
2026-12-05 17:39   ` netdev-bot+sashiko

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=179649235448.3146.5216638636094775268@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=SuperSkidder@qq.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hdanton@sina.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.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=willemb@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox