[openssh-commits] [openssh] branch master updated: upstream: revert:
git+noreply at mindrot.org
git+noreply at mindrot.org
Thu Nov 26 14:13:42 AEDT 2026
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
The following commit(s) were added to refs/heads/master by this push:
new 7374d90cd upstream: revert:
7374d90cd is described below
commit 7374d90cd4ece828202de17211ec85ece18e8b7f
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Thu Nov 26 03:12:24 2026 +0000
upstream: revert:
limit the number and total size of packets that we will queue
while KEX is running. Avoids possible DoS when KEX stalls and local
processes continue generating channel data for too long
Anthropic ANT-2026-Q1334JFN but with a separate threshold after which
the channels stop producing packets too
Causes hangs with multiplexed connections. Needs further debugging
OpenBSD-Commit-ID: 368b36d1a4d3b6f677e6a65659bdda88af20c633
---
channels.c | 4 ++--
packet.c | 42 +-----------------------------------------
packet.h | 3 +--
serverloop.c | 6 ++----
4 files changed, 6 insertions(+), 49 deletions(-)
diff --git a/channels.c b/channels.c
index 9cfc7bda9..48fb49024 100644
--- a/channels.c
+++ b/channels.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: channels.c,v 1.481 2026/11/25 22:14:23 djm Exp $ */
+/* $OpenBSD: channels.c,v 1.482 2026/11/26 03:12:24 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo at cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -2835,7 +2835,7 @@ channel_handler(struct ssh *ssh, int table, struct timespec *timeout)
if (c->type == SSH_CHANNEL_OPEN && c->bulk)
sc->nbulk++;
/* Try to keep IO going while rekeying */
- if (ssh_packet_can_enqueue(ssh) && c->type != SSH_CHANNEL_OPEN)
+ if (ssh_packet_is_rekeying(ssh) && c->type != SSH_CHANNEL_OPEN)
continue;
if (c->delayed) {
if (table == CHAN_PRE)
diff --git a/packet.c b/packet.c
index 1d0e5b1b0..ed0d40270 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.352 2026/11/25 22:14:23 djm Exp $ */
+/* $OpenBSD: packet.c,v 1.353 2026/11/26 03:12:24 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo at cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -99,18 +99,6 @@
#define PACKET_MAX_SIZE (256 * 1024)
-/*
- * Limits on the packets that may be queued for sending until a key exchange
- * completes. The queue is flushed to the output buffer in one go, so there
- * is no point in holding more data than could fit there.
- */
-#define PACKET_MAX_QUEUED (64 * 1024)
-#define PACKET_MAX_QUEUED_BYTES SSHBUF_SIZE_MAX
-
-/* Channels will keep enqueuing data until these thresholds are hit */
-#define PACKET_QUEUED_FULL ((3 * PACKET_MAX_QUEUED) / 4)
-#define PACKET_QUEUED_BYTES ((3 * PACKET_MAX_QUEUED_BYTES) / 4)
-
struct packet_state {
uint32_t seqnr;
uint32_t packets;
@@ -248,10 +236,7 @@ struct session_state {
ssh_packet_hook_fn *hook_in;
void *hook_in_ctx;
- /* Packets held by ssh_packet_send2() until key exchange completes */
TAILQ_HEAD(, packet) outgoing;
- u_int outgoing_npackets;
- size_t outgoing_nbytes;
};
struct ssh *
@@ -316,16 +301,6 @@ ssh_packet_is_rekeying(struct ssh *ssh)
(ssh->kex != NULL && ssh->kex->done == 0);
}
-/* Returns nonzero if a packet can be enqueued at this time */
-int
-ssh_packet_can_enqueue(struct ssh *ssh)
-{
- if (ssh == NULL || ssh->state == NULL || !ssh_packet_is_rekeying(ssh))
- return 1;
- return ssh->state->outgoing_npackets < PACKET_QUEUED_FULL &&
- ssh->state->outgoing_nbytes < PACKET_QUEUED_BYTES;
-}
-
/*
* Sets the descriptors used for communication.
*/
@@ -1460,25 +1435,12 @@ ssh_packet_send2(struct ssh *ssh)
if (need_rekey)
debug3_f("rekex triggered");
debug("enqueue packet: %u", type);
- /*
- * The queue only drains once the peer has completed the key
- * exchange. Don't let a peer that stalls it exhaust our memory.
- */
- if (state->outgoing_npackets >= PACKET_MAX_QUEUED ||
- sshbuf_len(state->outgoing_packet) >
- PACKET_MAX_QUEUED_BYTES - state->outgoing_nbytes) {
- error("too many packets queued while waiting for "
- "peer to complete key exchange");
- return SSH_ERR_NO_BUFFER_SPACE;
- }
p = calloc(1, sizeof(*p));
if (p == NULL)
return SSH_ERR_ALLOC_FAIL;
p->type = type;
p->payload = state->outgoing_packet;
TAILQ_INSERT_TAIL(&state->outgoing, p, next);
- state->outgoing_npackets++;
- state->outgoing_nbytes += sshbuf_len(p->payload);
state->outgoing_packet = sshbuf_new();
if (state->outgoing_packet == NULL)
return SSH_ERR_ALLOC_FAIL;
@@ -1520,8 +1482,6 @@ ssh_packet_send2(struct ssh *ssh)
sshbuf_free(state->outgoing_packet);
state->outgoing_packet = p->payload;
TAILQ_REMOVE(&state->outgoing, p, next);
- state->outgoing_npackets--;
- state->outgoing_nbytes -= sshbuf_len(p->payload);
memset(p, 0, sizeof(*p));
free(p);
if ((r = ssh_packet_send2_wrapped(ssh)) != 0)
diff --git a/packet.h b/packet.h
index 431367452..a1287185c 100644
--- a/packet.h
+++ b/packet.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.h,v 1.111 2026/11/25 22:14:23 djm Exp $ */
+/* $OpenBSD: packet.h,v 1.112 2026/11/26 03:12:24 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo at cs.hut.fi>
@@ -104,7 +104,6 @@ void ssh_packet_clear_keys(struct ssh *);
void ssh_clear_newkeys(struct ssh *, int);
int ssh_packet_is_rekeying(struct ssh *);
-int ssh_packet_can_enqueue(struct ssh *);
int ssh_packet_check_rekey(struct ssh *);
void ssh_packet_set_protocol_flags(struct ssh *, u_int);
u_int ssh_packet_get_protocol_flags(struct ssh *);
diff --git a/serverloop.c b/serverloop.c
index affd5feec..6f02fc1a6 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: serverloop.c,v 1.252 2026/11/25 22:14:23 djm Exp $ */
+/* $OpenBSD: serverloop.c,v 1.253 2026/11/26 03:12:24 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo at cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -389,9 +389,7 @@ server_loop2(struct ssh *ssh, Authctxt *authctxt)
if (sigprocmask(SIG_SETMASK, &osigset, NULL) == -1)
error_f("osigset sigprocmask: %s", strerror(errno));
- if (ssh_packet_can_enqueue(ssh))
- channel_after_poll(ssh, pfd, npfd_active);
-
+ channel_after_poll(ssh, pfd, npfd_active);
if (conn_in_ready &&
process_input(ssh, connection_in) < 0)
break;
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list