[nginx] Disabled repeated posts of write events without progress.

Maxim Dounin mdounin at mdounin.ru
Tue Nov 24 15:44:04 UTC 2026


details:   http://freenginx.org/hg/nginx/rev/f8ba4ceb0c9a
branches:  
changeset: 9616:f8ba4ceb0c9a
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Tue Nov 24 06:20:24 2026 +0300
description:
Disabled repeated posts of write events without progress.

Previously, since 7947:51a260276425 in write filter and
7949:862f6130d357 in output chain, write events were posted for the next
event loop operation if there were unsent data and the connection was
still ready for writing.  However, with SSL the c->write->ready flag
might still be set when writing isn't possible, such as when SSL_write()
returns SSL_ERROR_WANT_READ (which might be the case during a handshake
when responding to early data, or during renegotiation with an upstream
server).  This could cause some excessive CPU usage until the timeout
expires (known as CVE-2026-132779, though security impact in freenginx
is questionable).

The fix is to post write events only if some progress was made,
similarly to how we rearm write timeouts (9358:4c872940b19b).

See also:
https://github.com/nginx/nginx/commit/2c84628229bdeedd16db5980af6e8fdf754cc80d
https://github.com/nginx/nginx/commit/a12a232e6472b39a53b5e31266846843e142950d

diffstat:

 src/core/ngx_output_chain.c             |  6 ++++--
 src/http/ngx_http_write_filter_module.c |  2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diffs (42 lines):

diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -658,7 +658,7 @@ ngx_chain_writer(void *data, ngx_chain_t
 {
     ngx_chain_writer_ctx_t *ctx = data;
 
-    off_t              size;
+    off_t              size, sent;
     ngx_chain_t       *cl, *ln, *chain;
     ngx_connection_t  *c;
 
@@ -775,6 +775,8 @@ ngx_chain_writer(void *data, ngx_chain_t
         return NGX_OK;
     }
 
+    sent = c->sent;
+
     chain = c->send_chain(c, ctx->out, ctx->limit);
 
     ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0,
@@ -784,7 +786,7 @@ ngx_chain_writer(void *data, ngx_chain_t
         return NGX_ERROR;
     }
 
-    if (chain && c->write->ready) {
+    if (chain && c->write->ready && c->sent != sent) {
         ngx_post_event(c->write, &ngx_posted_next_events);
     }
 
diff --git a/src/http/ngx_http_write_filter_module.c b/src/http/ngx_http_write_filter_module.c
--- a/src/http/ngx_http_write_filter_module.c
+++ b/src/http/ngx_http_write_filter_module.c
@@ -336,7 +336,7 @@ ngx_http_write_filter(ngx_http_request_t
         }
     }
 
-    if (chain && c->write->ready && !c->write->delayed) {
+    if (chain && c->write->ready && !c->write->delayed && c->sent != sent) {
         ngx_post_event(c->write, &ngx_posted_next_events);
     }
 


More information about the nginx-devel mailing list