From e517c18d98c248e891558ce5194e3663d244f956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Fri, 31 May 2019 10:40:52 +0200 Subject: [PATCH 1/2] Fix a possible race between udp dispatch and socket code There's a small possibility of race between udp dispatcher and socket code - socket code can still hold internal reference to a socket while dispatcher calls isc_socket_open, which can cause an assertion failure. Fix it by relaxing the assertion test, and instead simply locking the socket in isc_socket_open. --- lib/isc/unix/socket.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 2c97e6e697..fc93d369b5 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -2596,15 +2596,16 @@ isc_socket_open(isc_socket_t *sock0) { REQUIRE(VALID_SOCKET(sock)); - REQUIRE(isc_refcount_current(&sock->references) == 1); - /* - * We don't need to retain the lock hereafter, since no one else has - * this socket. - */ + LOCK(&sock->lock); + + REQUIRE(isc_refcount_current(&sock->references) >= 1); REQUIRE(sock->fd == -1); REQUIRE(sock->threadid == -1); result = opensocket(sock->manager, sock, NULL); + + UNLOCK(&sock->lock); + if (result != ISC_R_SUCCESS) { sock->fd = -1; } else { From e56d95847bd15ad40be66e02c146d1f5e3a8e1e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Fri, 31 May 2019 20:16:58 +0200 Subject: [PATCH 2/2] CHANGES --- CHANGES | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES b/CHANGES index db2ac6a730..87f5e01a48 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +5243. [bug] Fix a possible race between dispatcher and socket + code in a high-load cold-cache resolver scenario. + [GL #943] + 5242. [bug] In relaxed qname minimizatiom mode, fall back to normal resolution when encountering a lame delegation, and use _.domain/A queries rather