2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Merge branch 'tcp-do-not-unthrottle-on_isc_nm_read' into 'v9.20.0-release'

[CVE-2024-0760 (part 2)] Do not un-throttle TCP connections on isc_nm_read()

See merge request isc-private/bind9!708
This commit is contained in:
Nicki Křížek
2024-06-25 08:54:47 +00:00
2 changed files with 18 additions and 3 deletions

View File

@@ -585,6 +585,12 @@ struct isc_nmsocket {
*/ */
uint64_t write_timeout; uint64_t write_timeout;
/*
* Reading was throttled over TCP as the peer does not read the
* data we are sending back.
*/
bool reading_throttled;
/*% outer socket is for 'wrapped' sockets - e.g. tcpdns in tcp */ /*% outer socket is for 'wrapped' sockets - e.g. tcpdns in tcp */
isc_nmsocket_t *outer; isc_nmsocket_t *outer;

View File

@@ -697,10 +697,12 @@ isc__nm_tcp_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg) {
goto failure; goto failure;
} }
if (!sock->reading_throttled) {
result = isc__nm_start_reading(sock); result = isc__nm_start_reading(sock);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
goto failure; goto failure;
} }
}
sock->reading = true; sock->reading = true;
@@ -791,6 +793,7 @@ isc__nm_tcp_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
"throttling TCP connection, the other side is " "throttling TCP connection, the other side is "
"not reading the data (%zu)", "not reading the data (%zu)",
write_queue_size); write_queue_size);
sock->reading_throttled = true;
isc__nm_stop_reading(sock); isc__nm_stop_reading(sock);
} }
} else if (uv_is_active(&sock->uv_handle.handle) && } else if (uv_is_active(&sock->uv_handle.handle) &&
@@ -1042,6 +1045,7 @@ tcp_maybe_restart_reading(isc_nmsocket_t *sock) {
"is reading the data again (%zu)", "is reading the data again (%zu)",
write_queue_size); write_queue_size);
isc__nm_start_reading(sock); isc__nm_start_reading(sock);
sock->reading_throttled = false;
} }
} }
} }
@@ -1064,6 +1068,11 @@ tcp_send_cb(uv_write_t *req, int status) {
isc__nm_failed_send_cb(sock, uvreq, isc_uverr2result(status), isc__nm_failed_send_cb(sock, uvreq, isc_uverr2result(status),
false); false);
if (!sock->client && sock->reading) { if (!sock->client && sock->reading) {
/*
* As we are resuming reading, it is not throttled
* anymore (technically).
*/
sock->reading_throttled = false;
isc__nm_start_reading(sock); isc__nm_start_reading(sock);
isc__nmsocket_reset(sock); isc__nmsocket_reset(sock);
} }