diff options
| author | Gustav Sennton <gsennton@google.com> | 2017-10-05 15:34:13 +0100 |
|---|---|---|
| committer | Gustav Sennton <gsennton@google.com> | 2017-10-05 15:49:10 +0100 |
| commit | ae498f270230e20b5a777ed2d6387a21767625a3 (patch) | |
| tree | a3a987afe4b59ff8bde6b3457d2c6a4a33be8768 /core/java/android | |
| parent | 36eaefa9cc58a3086256becd103234e607f80e8a (diff) | |
[WebView] Only pass one path to relro creation/loading at a time.
There's no need to send both 32-bit and 64-bit paths to the native side
of the relro-creation/loading logic, we can check which one to send on
the java side instead.
Bug: 28736099
Test: Load WebView app, ensure relro file is loaded into the app
process.
Change-Id: Ia3fb4b3ed686c3e70c26a384aae966bda179d225
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/webkit/WebViewFactory.java | 4 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewLibraryLoader.java | 30 |
2 files changed, 15 insertions, 19 deletions
diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java index 994512f7c897..e2b9b488bd72 100644 --- a/core/java/android/webkit/WebViewFactory.java +++ b/core/java/android/webkit/WebViewFactory.java @@ -446,13 +446,13 @@ public final class WebViewFactory { // waiting on relro creation. if (Build.SUPPORTED_32_BIT_ABIS.length > 0) { if (DEBUG) Log.v(LOGTAG, "Create 32 bit relro"); - WebViewLibraryLoader.createRelroFile(false /* is64Bit */, nativeLibraryPaths); + WebViewLibraryLoader.createRelroFile(false /* is64Bit */, nativeLibraryPaths[0]); numRelros++; } if (Build.SUPPORTED_64_BIT_ABIS.length > 0) { if (DEBUG) Log.v(LOGTAG, "Create 64 bit relro"); - WebViewLibraryLoader.createRelroFile(true /* is64Bit */, nativeLibraryPaths); + WebViewLibraryLoader.createRelroFile(true /* is64Bit */, nativeLibraryPaths[1]); numRelros++; } return numRelros; diff --git a/core/java/android/webkit/WebViewLibraryLoader.java b/core/java/android/webkit/WebViewLibraryLoader.java index 6f9e8ece4b13..db722d51ea5f 100644 --- a/core/java/android/webkit/WebViewLibraryLoader.java +++ b/core/java/android/webkit/WebViewLibraryLoader.java @@ -62,20 +62,18 @@ class WebViewLibraryLoader { boolean result = false; boolean is64Bit = VMRuntime.getRuntime().is64Bit(); try { - if (args.length != 2 || args[0] == null || args[1] == null) { + if (args.length != 1 || args[0] == null) { Log.e(LOGTAG, "Invalid RelroFileCreator args: " + Arrays.toString(args)); return; } - Log.v(LOGTAG, "RelroFileCreator (64bit = " + is64Bit + "), " - + " 32-bit lib: " + args[0] + ", 64-bit lib: " + args[1]); + Log.v(LOGTAG, "RelroFileCreator (64bit = " + is64Bit + "), lib: " + args[0]); if (!sAddressSpaceReserved) { Log.e(LOGTAG, "can't create relro file; address space not reserved"); return; } - result = nativeCreateRelroFile(args[0] /* path32 */, - args[1] /* path64 */, - CHROMIUM_WEBVIEW_NATIVE_RELRO_32, - CHROMIUM_WEBVIEW_NATIVE_RELRO_64); + result = nativeCreateRelroFile(args[0] /* path */, + is64Bit ? CHROMIUM_WEBVIEW_NATIVE_RELRO_64 : + CHROMIUM_WEBVIEW_NATIVE_RELRO_32); if (result && DEBUG) Log.v(LOGTAG, "created relro file"); } finally { // We must do our best to always notify the update service, even if something fails. @@ -96,7 +94,7 @@ class WebViewLibraryLoader { /** * Create a single relro file by invoking an isolated process that to do the actual work. */ - static void createRelroFile(final boolean is64Bit, String[] nativeLibraryPaths) { + static void createRelroFile(final boolean is64Bit, String nativeLibraryPath) { final String abi = is64Bit ? Build.SUPPORTED_64_BIT_ABIS[0] : Build.SUPPORTED_32_BIT_ABIS[0]; @@ -114,13 +112,12 @@ class WebViewLibraryLoader { }; try { - if (nativeLibraryPaths == null - || nativeLibraryPaths[0] == null || nativeLibraryPaths[1] == null) { + if (nativeLibraryPath == null) { throw new IllegalArgumentException( "Native library paths to the WebView RelRo process must not be null!"); } int pid = LocalServices.getService(ActivityManagerInternal.class).startIsolatedProcess( - RelroFileCreator.class.getName(), nativeLibraryPaths, + RelroFileCreator.class.getName(), new String[] { nativeLibraryPath }, "WebViewLoader-" + abi, abi, Process.SHARED_RELRO_UID, crashHandler); if (pid <= 0) throw new Exception("Failed to start the relro file creator process"); } catch (Throwable t) { @@ -217,8 +214,9 @@ class WebViewLibraryLoader { final String libraryFileName = WebViewFactory.getWebViewLibrary(packageInfo.applicationInfo); - int result = nativeLoadWithRelroFile(libraryFileName, CHROMIUM_WEBVIEW_NATIVE_RELRO_32, - CHROMIUM_WEBVIEW_NATIVE_RELRO_64, clazzLoader); + String relroPath = VMRuntime.getRuntime().is64Bit() ? CHROMIUM_WEBVIEW_NATIVE_RELRO_64 : + CHROMIUM_WEBVIEW_NATIVE_RELRO_32; + int result = nativeLoadWithRelroFile(libraryFileName, relroPath, clazzLoader); if (result != WebViewFactory.LIBLOAD_SUCCESS) { Log.w(LOGTAG, "failed to load with relro file, proceeding without"); } else if (DEBUG) { @@ -313,8 +311,6 @@ class WebViewLibraryLoader { } static native boolean nativeReserveAddressSpace(long addressSpaceToReserve); - static native boolean nativeCreateRelroFile(String lib32, String lib64, - String relro32, String relro64); - static native int nativeLoadWithRelroFile(String lib, String relro32, String relro64, - ClassLoader clazzLoader); + static native boolean nativeCreateRelroFile(String lib, String relro); + static native int nativeLoadWithRelroFile(String lib, String relro, ClassLoader clazzLoader); } |
