]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mworker: don't register mworker_accept_wrapper() when master FD is wrong
authorWilliam Lallemand <wlallemand@haproxy.org>
Tue, 21 Feb 2023 12:41:24 +0000 (13:41 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Tue, 21 Feb 2023 12:53:35 +0000 (13:53 +0100)
This patch handles the case where the fd could be -1 when proc_self was
lost for some reason (environment variable corrupted or upgrade from < 1.9).

This could result in a out of bound array access fdtab[-1] and would crash.

Must be backported in every maintained versions.

src/mworker.c

index e6c8e51b0d83b85ccd469ee955bc667a4ad8b67f..d71bf615648d6c963106ccad9ba23a882e6b2b65 100644 (file)
@@ -470,6 +470,9 @@ static int mworker_sockpair_register_per_thread()
        if (tid != 0)
                return 1;
 
+       if (proc_self->ipc_fd[1] < 0) /* proc_self was incomplete and we can't find the socketpair */
+               return 1;
+
        fd_set_nonblock(proc_self->ipc_fd[1]);
        /* register the wrapper to handle read 0 when the master exits */
        fdtab[proc_self->ipc_fd[1]].iocb = mworker_accept_wrapper;