Tunnel disconnects with "peer ignored channel window"

Troy Pocklington tpocklington at scalecomputing.com
Sat Nov 14 15:00:41 AEDT 2026


Hi,

Picking this thread back up from October 2025
(https://lists.mindrot.org/pipermail/openssh-unix-dev/2025-October/042185.html):
I've been chasing the same disconnects on an ssh -w point-to-point
tunnel between two Linux hosts, with a distribution build of 9.9p1 as
the receiving sshd and distribution builds of 7.4p1 and 8.7p1 as the
clients. I think there is a channel window accounting bug here. I can
reproduce it with current master on both ends as well.

Each end keeps its own copy of the channel window, and the two ends
don't agree on how much a datagram takes out of it. For a datagram of
N bytes:

1. The sender subtracts N from its copy (`c->remote_window -= plen` in
channel_output_poll_input_open()). It has done this since 6.9
(f715afebe, "Fix math error in remote window calculations that causes
eventual stalls for datagram channels"). Before that it subtracted N +
4.
2. The receiver subtracts N + 4 from its copy (the `win_len += 4`
mentioned in a previous message in the thread).
3. Once the receiver has written the datagram to the tun device, it
adds N + 4 back to its copy and sends a window adjust telling the
sender to add N + 4 back too. It's N + 4 because channel_handle_wfd()
adds back however much c->output shrank, and the datagram was queued
there with its 4-byte length header.

So the receiver's copy returns to where it started, but the sender's
copy ends up 4 bytes larger for every datagram. The difference builds
up until the window next runs out, and then the sender sends up to
that much more than the receiver will accept. Before 9.6 that showed
up as "rcvd too much data" drops. Since 9.6 the receiver disconnects
once a run of excess passes 10% of the window. With the default
window, that takes about 52,000 datagrams between the times the window
runs out. So the bug dates from 6.9, and 9.6's stricter window check
is what turned it from packet drops into disconnects.

The attached patch against master (1d28115e0), "channels: Don't count
datagram length headers in the window", makes the receiver subtract N
when a datagram arrives and add back N once it has been written out,
matching the sender. It's a receiver-only change, so it works with any
sender since 6.9. Removing only the `win_len += 4` line isn't enough:
the receiver then subtracts N but still adds back N + 4, so both
copies grow by 4 bytes per datagram without bound, and once the window
passes local_window_max the receiver sends a window adjust for nearly
every datagram.

I've also filed this as bug 4055
(https://bugzilla.mindrot.org/show_bug.cgi?id=4055), with the patch
and a reproducer script attached. On master, without the patch, the
reproducer's server disconnected every time the window ran out. With
the patch it never overran or disconnected.

One compatibility catch: senders from 6.8 and earlier still subtract N
+ 4. A patched receiver adds back only N, so their copy of the window
shrinks 4 bytes per datagram, and the tunnel eventually stalls. If
those peers matter, the receiver could keep the +4 for them with a
compat flag.

Thanks,
Troy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tun-window.patch
Type: text/x-patch
Size: 2256 bytes
Desc: not available
URL: <http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20261113/b10fea0b/attachment.bin>


More information about the openssh-unix-dev mailing list