From a85e9d5032fdf305457a6400bd3af4a8df6c45c4 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 21 Oct 2024 11:53:43 +0200 Subject: executor: check ppid after setting PR_SET_PDEATHSIG for sandbox process This helps to avoid leaking processes when killing races with PR_SET_PDEATHSIG. --- executor/common_linux.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'executor/common_linux.h') diff --git a/executor/common_linux.h b/executor/common_linux.h index 54dbdc8b2..562fe703b 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -4044,6 +4044,8 @@ static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); + if (getppid() == 1) + exitf("the sandbox parent process was killed"); #if SYZ_EXECUTOR || __NR_syz_init_net_socket || SYZ_DEVLINK_PCI || __NR_syz_socket_connect_nvme_tcp int netns = open("/proc/self/ns/net", O_RDONLY); @@ -4857,6 +4859,8 @@ static void reset_loop() static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); + // We don't check for getppid() == 1 here b/c of unshare(CLONE_NEWPID), + // our parent is normally pid 1. setpgrp(); #if SYZ_EXECUTOR || SYZ_CGROUPS setup_cgroups_test(); -- cgit mrf-deployment