summaryrefslogtreecommitdiffstats
path: root/core/java/com/android
diff options
context:
space:
mode:
authormqi <mqi@codeaurora.org>2015-06-01 14:59:31 +0800
committerSteve Kondik <shade@chemlab.org>2016-07-26 09:47:00 -0700
commit87fd250c5fa2aad3738f6b03fa7e16d274abb506 (patch)
tree42aa98eb5aacac6bb14ac74755e7f57f9452d279 /core/java/com/android
parent75c84499bde3e8e0555cd9fda1cde5d758a8b8d4 (diff)
downloadframeworks_base-87fd250c5fa2aad3738f6b03fa7e16d274abb506.zip
frameworks_base-87fd250c5fa2aad3738f6b03fa7e16d274abb506.tar.gz
frameworks_base-87fd250c5fa2aad3738f6b03fa7e16d274abb506.tar.bz2
Improve the scan process
Use multi task to speed up the scan process CRs-Fixed: 984513 base: fix native crash in system_server Currently PackageManagerService uses multi-thread to scan packages to speed up, when scan each package, it sometimes will call SELinux's restorecon, then libselinux uses global variable fc_sehandle to selabel_lookup and write in compile_regex, so it's not thread-safe, so will cause invalid address with possibility. From backtrace, the final crash happens in pcre_exec. Add one lock in NativeLibraryHelper to make restorecon safe. Change-Id: Ida43fcda01d3450befea6afa0be5da27bb195def CRs-Fixed: 1002406, 1027381
Diffstat (limited to 'core/java/com/android')
-rw-r--r--core/java/com/android/internal/content/NativeLibraryHelper.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/java/com/android/internal/content/NativeLibraryHelper.java b/core/java/com/android/internal/content/NativeLibraryHelper.java
index f479f4f..f5b948f 100644
--- a/core/java/com/android/internal/content/NativeLibraryHelper.java
+++ b/core/java/com/android/internal/content/NativeLibraryHelper.java
@@ -62,6 +62,8 @@ public class NativeLibraryHelper {
// that the cpuAbiOverride must be clear.
public static final String CLEAR_ABI_OVERRIDE = "-";
+ private static final Object mRestoreconSync = new Object();
+
/**
* A handle to an opened package, consisting of one or more APKs. Used as
* input to the various NativeLibraryHelper methods. Allows us to scan and
@@ -275,8 +277,12 @@ public class NativeLibraryHelper {
throw new IOException("Cannot chmod native library directory "
+ path.getPath(), e);
}
- } else if (!SELinux.restorecon(path)) {
- throw new IOException("Cannot set SELinux context for " + path.getPath());
+ } else {
+ synchronized (mRestoreconSync) {
+ if (!SELinux.restorecon(path)) {
+ throw new IOException("Cannot set SELinux context for " + path.getPath());
+ }
+ }
}
}