From 718a317dc7dbf836b604073e477ce4029272f321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Sat, 20 Jul 2019 16:10:49 -0400 Subject: [PATCH] Fix unprotected access to thread->epoll_events[fd] in unwatch_fd() --- lib/isc/unix/socket.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 7c53ec2325..5063619880 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -881,17 +881,15 @@ wakeup_socket(isc__socketthread_t *thread, int fd, int msg) { LOCK(&thread->fdlock[lockid]); INSIST(thread->fdstate[fd] == CLOSE_PENDING); thread->fdstate[fd] = CLOSED; - UNLOCK(&thread->fdlock[lockid]); (void)unwatch_fd(thread, fd, SELECT_POKE_READ); (void)unwatch_fd(thread, fd, SELECT_POKE_WRITE); (void)close(fd); + UNLOCK(&thread->fdlock[lockid]); return; } LOCK(&thread->fdlock[lockid]); if (thread->fdstate[fd] == CLOSE_PENDING) { - UNLOCK(&thread->fdlock[lockid]); - /* * We accept (and ignore) any error from unwatch_fd() as we are * closing the socket, hoping it doesn't leave dangling state in @@ -902,6 +900,7 @@ wakeup_socket(isc__socketthread_t *thread, int fd, int msg) { */ (void)unwatch_fd(thread, fd, SELECT_POKE_READ); (void)unwatch_fd(thread, fd, SELECT_POKE_WRITE); + UNLOCK(&thread->fdlock[lockid]); return; } if (thread->fdstate[fd] != MANAGED) {