From: Mark Andrews Date: Tue, 7 Jul 2020 01:11:15 +0000 (+1000) Subject: Address potential double unlock in process_fd X-Git-Tag: v9.17.4~51^2~1 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=cc0089c66b692d554e8fc927e4f47e3d7dcda371;p=thirdparty%2Fbind9.git Address potential double unlock in process_fd --- diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index ee0f2f2596c..ff1f147871d 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -3072,7 +3072,6 @@ finish: unwatch_fd(&sock->manager->threads[sock->threadid], sock->fd, SELECT_POKE_READ); } - UNLOCK(&sock->lock); } static void @@ -3112,7 +3111,6 @@ finish: unwatch_fd(&sock->manager->threads[sock->threadid], sock->fd, SELECT_POKE_WRITE); } - UNLOCK(&sock->lock); } /* @@ -3158,14 +3156,6 @@ process_fd(isc__socketthread_t *thread, int fd, bool readable, bool writeable) { } REQUIRE(readable || writeable); - if (readable) { - if (sock->listener) { - internal_accept(sock); - } else { - internal_recv(sock); - } - } - if (writeable) { if (sock->connecting) { internal_connect(sock); @@ -3174,7 +3164,17 @@ process_fd(isc__socketthread_t *thread, int fd, bool readable, bool writeable) { } } - /* sock->lock is unlocked in internal_* function */ + if (readable) { + if (sock->listener) { + internal_accept(sock); /* unlocks sock */ + } else { + internal_recv(sock); + UNLOCK(&sock->lock); + } + } else { + UNLOCK(&sock->lock); + } + UNLOCK(&thread->fdlock[lockid]); /* @@ -4950,7 +4950,6 @@ internal_connect(isc__socket_t *sock) { finish: unwatch_fd(&sock->manager->threads[sock->threadid], sock->fd, SELECT_POKE_CONNECT); - UNLOCK(&sock->lock); } isc_result_t