summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2014-04-29 22:34:54 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-04-29 22:34:54 +0000
commitd37ae7c13d527a0019275fda44ce4eb83fd99bed (patch)
tree9e81ce188574bf62e4d16e8402b843b10faca1bc /cmds
parent15c32f2699f03ba2065e663b3beb2c8d328f42ef (diff)
parentab5834545da906f1a150672ead825c28a2e1f82a (diff)
downloadframeworks_base-d37ae7c13d527a0019275fda44ce4eb83fd99bed.zip
frameworks_base-d37ae7c13d527a0019275fda44ce4eb83fd99bed.tar.gz
frameworks_base-d37ae7c13d527a0019275fda44ce4eb83fd99bed.tar.bz2
am ab583454: am 1866e5dc: am af40649e: Merge "Set NO_NEW_PRIVS on zygote init"
* commit 'ab5834545da906f1a150672ead825c28a2e1f82a': Set NO_NEW_PRIVS on zygote init
Diffstat (limited to 'cmds')
-rw-r--r--cmds/app_process/app_main.cpp10
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]