]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dns-stream: only read DNS packet data if we identified the peer properly 36531/head
authorLennart Poettering <lennart@poettering.net>
Mon, 3 Mar 2025 23:17:21 +0000 (00:17 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 4 Mar 2025 12:33:53 +0000 (12:33 +0000)
If we use TCP fastopen to connect to a DNS server via TCP, and it
responds really quickly between our connection attempt and our immediate
check back, then we have not identified the peer yet, and will not be
able to use the peer metadata to fill in our packet info.

Let's fix that, and simply not read from the socket until identification
is complete.

Fixes: #34956
src/resolve/resolved-dns-stream.c

index 0696857802fe014d28e9e29879b0e9bf9fbd417a..7545065bae6b4366b034336ceb6dda1db74da421 100644 (file)
@@ -360,7 +360,8 @@ static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *use
                 }
         }
 
-        while ((revents & (EPOLLIN|EPOLLHUP|EPOLLRDHUP)) &&
+        while (s->identified && /* Only read data once we identified the peer, because we cannot fill in the DNS packet meta info otherwise */
+               (revents & (EPOLLIN|EPOLLHUP|EPOLLRDHUP)) &&
                (!s->read_packet ||
                 s->n_read < sizeof(s->read_size) + s->read_packet->size)) {