summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorVictor Hsieh <victorhsieh@google.com>2018-01-08 12:43:00 -0800
committerVictor Hsieh <victorhsieh@google.com>2018-01-17 09:30:44 -0800
commitc8176efe2e2dc3aadc69c32b6aa9180751778e8f (patch)
treed770a17ed5570a4d04ff0a1acb8de45f3b2b2991 /core/java
parent106a915256abeebf6ce91165323caf50a16b4782 (diff)
Reland: Move zygote's seccomp setup to post-fork
Before this change, seccomp filter setup is as early as in zygote's main function. To make it possible to split app and system server's filter, this postpone the setup to after fork. It also starts to call app specific and system server specific setup function. The filter setup is done in Zygote's ForkAndSpecializeCommon. This is because adding a seccomp filter must be done when either the caller has CAP_SYS_ADMIN or after the PR_SET_NO_NEW_PRIVS bit is set. Given that setting PR_SET_NO_NEW_PRIVS breaks SELinux domain transition (b/71859146), this must be done after Zygote forks but before CAP_SYS_ADMIN is droppped. Test: (cts) -m CtsSecurityTestCases -t android.security.cts.SeccompTest Test: no selinux denial flood in dmesg with selinux enforced Test: debuggerd -b `pidof com.android.phone` # logcat shows tombstoned received crash request Bug: 63944145 Bug: 71859146 Change-Id: I8215c8530d3d0de504a270488f8e29635805e8b0
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/os/Seccomp.java24
-rw-r--r--core/java/com/android/internal/os/Zygote.java3
-rw-r--r--core/java/com/android/internal/os/ZygoteInit.java6
3 files changed, 5 insertions, 28 deletions
diff --git a/core/java/android/os/Seccomp.java b/core/java/android/os/Seccomp.java
deleted file mode 100644
index f14e93fe9403..000000000000
--- a/core/java/android/os/Seccomp.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.os;
-
-/**
- * @hide
- */
-public final class Seccomp {
- public static final native void setPolicy();
-}
diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java
index 3ee8b472869b..9167076474ff 100644
--- a/core/java/com/android/internal/os/Zygote.java
+++ b/core/java/com/android/internal/os/Zygote.java
@@ -69,6 +69,9 @@ public final class Zygote {
private Zygote() {}
+ /** Called for some security initialization before any fork. */
+ native static void nativeSecurityInit();
+
/**
* Forks a new VM instance. The current VM must have been started
* with the -Xzygote flag. <b>NOTE: new instance keeps all
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index 212cdcbce0b1..21f1fb652794 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -30,7 +30,6 @@ import android.os.IInstalld;
import android.os.Environment;
import android.os.Process;
import android.os.RemoteException;
-import android.os.Seccomp;
import android.os.ServiceManager;
import android.os.ServiceSpecificException;
import android.os.SystemClock;
@@ -781,12 +780,11 @@ public class ZygoteInit {
// Zygote.
Trace.setTracingEnabled(false, 0);
+ Zygote.nativeSecurityInit();
+
// Zygote process unmounts root storage spaces.
Zygote.nativeUnmountStorageOnInit();
- // Set seccomp policy
- Seccomp.setPolicy();
-
ZygoteHooks.stopZygoteNoThreadCreation();
if (startSystemServer) {