diff options
author | Nick Kralevich <nnk@google.com> | 2014-04-25 15:01:24 -0700 |
---|---|---|
committer | Nick Kralevich <nnk@google.com> | 2014-04-29 15:10:58 -0700 |
commit | 195c73c9b2c5be50ab325099dc2160215ac7562a (patch) | |
tree | d96f10bd5467d1c3788e9393a6b9f5ee367c0b2c /cmds | |
parent | 5c220cc4e4c0584a9083529b58e30e17ab7d2d9e (diff) | |
download | frameworks_base-195c73c9b2c5be50ab325099dc2160215ac7562a.zip frameworks_base-195c73c9b2c5be50ab325099dc2160215ac7562a.tar.gz frameworks_base-195c73c9b2c5be50ab325099dc2160215ac7562a.tar.bz2 |
Set NO_NEW_PRIVS on zygote init
When app_process/zygote starts, make sure PR_SET_NO_NEW_PRIVS is set.
This prevents zygote spawned apps from acquiring new privileges
on exec.
In particular, this allows the CTS test
android.os.cts.SecurityFeaturesTest#testNoNewPrivs() to pass if ART is set
as the default runtime.
Change-Id: I81139cda999c7b1430242561aad28f566e9b6da0
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/app_process/app_main.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp index 3481437..82d13a6 100644 --- a/cmds/app_process/app_main.cpp +++ b/cmds/app_process/app_main.cpp @@ -19,6 +19,7 @@ #include <stdlib.h> #include <stdio.h> #include <unistd.h> +#include <sys/prctl.h> namespace android { @@ -146,6 +147,15 @@ static const char ZYGOTE_NICE_NAME[] = "zygote"; int main(int argc, char* const argv[]) { + if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) < 0) { + // Older kernels don't understand PR_SET_NO_NEW_PRIVS and return + // EINVAL. Don't die on such kernels. + if (errno != EINVAL) { + LOG_ALWAYS_FATAL("PR_SET_NO_NEW_PRIVS failed: %s", strerror(errno)); + return 12; + } + } + AppRuntime runtime(argv[0], computeArgBlockSize(argc, argv)); // Process command line arguments // ignore argv[0] |