From d16a9dfed80e75d730754b717370515265698cdd Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Mon, 25 Feb 2019 16:18:16 +0100 Subject: [PATCH] BUG/MAJOR: listener: Make sure the listener exist before using it. In listener_accept(), make sure we have a listener before attempting to use it. An another thread may have closed the FD meanwhile, and set fdtab[fd].owner to NULL. As the listener is not free'd, it is ok to attempt to accept() a new connection even if the listener was closed. At worst the fd has been reassigned to another connection, and accept() will fail anyway. Many thanks to Richard Russo for reporting the problem, and suggesting the fix. This should be backported to 1.9 and 1.8. --- src/listener.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/listener.c b/src/listener.c index e9ace41f5..4d080310d 100644 --- a/src/listener.c +++ b/src/listener.c @@ -448,8 +448,8 @@ void delete_listener(struct listener *listener) void listener_accept(int fd) { struct listener *l = fdtab[fd].owner; - struct proxy *p = l->bind_conf->frontend; - int max_accept = l->maxaccept ? l->maxaccept : 1; + struct proxy *p; + int max_accept; int expire; int cfd; int ret; @@ -457,6 +457,10 @@ void listener_accept(int fd) static int accept4_broken; #endif + if (!l) + return; + p = l->bind_conf->frontend; + max_accept = l->maxaccept ? l->maxaccept : 1; if (HA_SPIN_TRYLOCK(LISTENER_LOCK, &l->lock)) return;