From 18309ff64833523c1ad19e7d56d6f756b53966af Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Mon, 27 Oct 2025 22:33:02 +0100 Subject: [PATCH] Avoid possible race condition that kill OpenVPN itself 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 Found-By: Zeropath Change-Id: I7b94de92723f9528b01cb932bb079eedf0f1f272 Signed-off-by: Arne Schwabe Acked-by: Gert Doering 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 --- src/openvpn/tun_afunix.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/openvpn/tun_afunix.c b/src/openvpn/tun_afunix.c index 4d48a318a..124db6d98 100644 --- a/src/openvpn/tun_afunix.c +++ b/src/openvpn/tun_afunix.c @@ -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); -- 2.47.3