[Bug 4065] New: Window accounting mismatch on datagram (tun) channels causes "peer ignored channel window" disconnects
bugzilla-daemon at mindrot.org
bugzilla-daemon at mindrot.org
Tue Nov 24 11:58:20 AEDT 2026
https://bugzilla.mindrot.org/show_bug.cgi?id=4065
Bug ID: 4065
Summary: Window accounting mismatch on datagram (tun) channels
causes "peer ignored channel window" disconnects
Product: Portable OpenSSH
Version: -current
Hardware: amd64
OS: Linux
Status: NEW
Severity: normal
Priority: P5
Component: ssh
Assignee: unassigned-bugs at mindrot.org
Reporter: khasanov--ruslan at yandex.ru
Created attachment 4036
--> https://bugzilla.mindrot.org/attachment.cgi?id=4036&action=edit
Fix window accounting for datagram (tun) channels
For datagram channels (tun forwarding, ssh -w) the sender and the
receiver disagree on how much window a datagram consumes.
channel_input_data() charges data_len + 4 (string length header) to
local_window, and channel_handle_wfd() later credits the same amount
back (local_consumed += olen - sshbuf_len(c->output), which includes
the header). channel_output_poll_input_open() on the sending side only
does "c->remote_window -= plen".
The sender's view of the remote window therefore grows by 4 bytes per
datagram, without bound. Once the real window fills up (sustained load,
or a latency spike on the outer TCP connection) the sender overruns it
by the accumulated drift; the receiver logs bursts of
channel 1: rcvd too much data 1458, win 0/2097152 (excess ...)
and, once the excess exceeds 10% of the window, disconnects with
"peer ignored channel window". In our setup an ssh -w tunnel carrying
a few Mbit/s of mixed traffic was disconnected every 30-40 seconds.
Fix: account for the 4-byte header on the sending side too (both in
the "datagram fits" check and when decrementing remote_window). This
only makes the sender more conservative, so it interoperates with
unpatched peers.
A second, related issue: in channel_handle_wfd() a datagram dropped
because write() to the tun fd returned EAGAIN/EINTR has already been
removed from c->output but is never credited to local_consumed, so its
window space leaks. Credit it as consumed.
History / prior reports:
- openssh-unix-dev, Oct 2025, "Tunnel disconnects with 'peer ignored
channel window'" - same symptom. Removing the receiver-side
"win_len += 4" (as suggested there) does not fix it consistently:
channel_handle_wfd() still credits the header, so the receiver then
over-credits and flow control silently stops working.
https://lists.mindrot.org/pipermail/openssh-unix-dev/2025-October/042188.html
- f715afebe (2015) changed the sender from "remote_window -= dlen + 4"
to "-= dlen" to fix a u_int underflow (the fits check was
"dlen > remote_window"); that introduced the drift. The patch adds +4
to both the check and the decrement.
- Possibly related: bz#3231 (tun hang at high rates, pre-0cb50eefd,
when over-window data was silently dropped).
Patches attached (git format-patch against master, 2 commits).
GitHub PR: https://github.com/openssh/openssh-portable/pull/746
Tested: master builds cleanly and unit tests pass; the change
backported
to Debian 13 / Ubuntu 26.04 / Ubuntu 24.04 packages and deployed on
both
ends of a production ssh -w tunnel stopped the disconnects.
--
You are receiving this mail because:
You are watching the assignee of the bug.
More information about the openssh-bugs
mailing list