Terminate TCP child processes that arise from UDP truncated replies.

These can't be held forever by a client that opens a connection and
then sends nothing, but we can still be DoSsed by a server which
accepts a connection and never replies.

If the TCP process times out, it sends that information to the
parent so that the UDP query can be unblocked. As the TCP
timeout is 150s it's highly unlikely that any client will
still be waiting, but the point is to free resources.
This commit is contained in:
Simon Kelley committed 2025-12-07 15:00:29 +00:00
1 parent fa48bdb939
commit c090f1d17b
4 files changed
+63 -13

No files matched your search

+5 -1
View File
@@ -2223,7 +2223,7 @@ int tcp_from_udp(time_t now, int status, struct dns_header *header, ssize_t *ple
if (n >= daemon->edns_pktsz)
{
/* still too bIg, strip optional sections and try again. */
/* still too big, strip optional sections and try again. */
new_header->nscount = htons(0);
new_header->arcount = htons(0);
n = resize_packet(new_header, n, NULL, 0);
@@ -2237,6 +2237,10 @@ int tcp_from_udp(time_t now, int status, struct dns_header *header, ssize_t *ple
}
}
/* we have succeeded and are no longer blocked talking
on a TCP connection, so if the watchdog alarm goes off,
ignore it. */
daemon->forward_to_tcp = NULL;
/* return the stripped or truncated reply. */
memcpy(header, new_header, n);
*plenp = n;