]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Avoid possible race condition that kill OpenVPN itself
authorArne Schwabe <arne@rfc2549.org>
Mon, 27 Oct 2025 21:33:02 +0000 (22:33 +0100)
committerGert Doering <gert@greenie.muc.de>
Tue, 28 Oct 2025 09:31:01 +0000 (10:31 +0100)
If for whatever reason the child pid is zero, we would kill ourselves
since killing 0 means killing the own process group.

Reported-By: Joshua Rogers <contact@joshua.hu>
Found-By: Zeropath
Change-Id: I7b94de92723f9528b01cb932bb079eedf0f1f272
Signed-off-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1319
Message-Id: <20251027213308.5588-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33910.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/tun_afunix.c

index 4d48a318afe9d124586fc96c7a0d6cea0ad2bf2e..124db6d98106168a4a7db1ce975571e99695d0b6 100644 (file)
@@ -128,7 +128,12 @@ close_tun_afunix(struct tuntap *tt)
         close(tt->fd);
         tt->fd = 0;
     }
-    kill(tt->afunix.childprocess, SIGINT);
+    /* only kill the child process if the PID is not 0 to avoid killing
+     * ourselves by accident */
+    if (tt->afunix.childprocess)
+    {
+        kill(tt->afunix.childprocess, SIGINT);
+    }
 
     free(tt->actual_name);
     free(tt);