aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_linux.h
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@google.com>2020-10-09 10:44:28 -0700
committerDmitry Vyukov <dvyukov@google.com>2020-10-09 21:48:35 +0200
commit93817d892548db363431ebb7f31518df0d8582ec (patch)
treec94b9dd892cea496c4e3d00105f96c7e614c6f7a /executor/common_linux.h
parentdcf117a24d23d280b2e9128caac89cea86de617a (diff)
executor: set parent-death signal after changing user or group ID-s
The parent-death signal is set in sandbox_common, but then setresuid and setresgid clear it and we need to set it again. Signed-off-by: Andrei Vagin <avagin@google.com>
Diffstat (limited to 'executor/common_linux.h')
-rw-r--r--executor/common_linux.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h
index 402892dac..146984b3b 100644
--- a/executor/common_linux.h
+++ b/executor/common_linux.h
@@ -3772,6 +3772,8 @@ static int do_sandbox_setuid(void)
if (syscall(SYS_setresuid, nobody, nobody, nobody))
fail("failed to setresuid");
+ // setresuid and setresgid clear the parent-death signal.
+ prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
// This is required to open /proc/self/ files.
// Otherwise they are owned by root and we can't open them after setuid.
// See task_dump_owner function in kernel.
@@ -4067,6 +4069,9 @@ static int do_sandbox_android(void)
if (setresuid(UNTRUSTED_APP_UID, UNTRUSTED_APP_UID, UNTRUSTED_APP_UID) != 0)
fail("setresuid failed");
+ // setresuid and setresgid clear the parent-death signal.
+ prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
+
syz_setfilecon(".", SELINUX_LABEL_APP_DATA_FILE);
syz_setcon(SELINUX_CONTEXT_UNTRUSTED_APP);