diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-10-21 11:53:43 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-10-24 09:34:38 +0000 |
| commit | a85e9d5032fdf305457a6400bd3af4a8df6c45c4 (patch) | |
| tree | 2ef50ef4418204f2fa2d9e68d720b221fe4869b3 | |
| parent | 0b321648703e03ecd7aa098b7b57a479dc7c97d4 (diff) | |
executor: check ppid after setting PR_SET_PDEATHSIG for sandbox process
This helps to avoid leaking processes when killing races with PR_SET_PDEATHSIG.
| -rw-r--r-- | executor/common_linux.h | 4 |
1 files changed, 4 insertions, 0 deletions
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(); |
