From 23dad533ff5a6f1ebcbccd15d364a52a433a6e6d Mon Sep 17 00:00:00 2001 From: "mseaborn@chromium.org" Date: Sat, 8 Mar 2014 23:07:33 +0000 Subject: [PATCH] NaCl: Remove PNaCl's IRT interface whitelist from the PNaCl IRT shims Disabling various IRT interfaces under PNaCl is now done in the NaCl repo by irt_interfaces.c, as long as pnacl_mode is set to true in nacl_listener.cc. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3803 TEST=PnaclExceptionHandlingDisabled, PnaclDyncodeSyscallDisabled R=jvoung@chromium.org Review URL: https://codereview.chromium.org/191503002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255799 0039d316-1c4b-4281-b951-d872f2087c98 --- components/nacl/loader/nacl_listener.cc | 5 ++ .../src/untrusted/pnacl_irt_shim/shim_ppapi.c | 74 ------------------- 2 files changed, 5 insertions(+), 74 deletions(-) diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc index d2222acfa642ee..4a4efef7c0be2a 100644 --- a/components/nacl/loader/nacl_listener.cc +++ b/components/nacl/loader/nacl_listener.cc @@ -402,6 +402,11 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) { // PNaCl because it might break existing NaCl apps, and this limit // is only useful if the dyncode syscalls are disabled. args->initial_nexe_max_code_bytes = 32 << 20; // 32 MB + + // Indicate that this is a PNaCl module. + // TODO(jvoung): Plumb through something indicating that this is PNaCl + // instead of relying on enable_dyncode_syscalls. + args->pnacl_mode = 1; } #if defined(OS_LINUX) || defined(OS_MACOSX) args->debug_stub_server_bound_socket_fd = nacl::ToNativeHandle( diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.c index 27f6ee7e5a9678..5e111c14c0db63 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.c @@ -7,88 +7,17 @@ #include "ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.h" #include -#include "native_client/src/include/nacl_macros.h" #include "native_client/src/untrusted/irt/irt.h" -#include "native_client/src/untrusted/irt/irt_dev.h" #include "ppapi/nacl_irt/irt_ppapi.h" #include "ppapi/native_client/src/shared/ppapi_proxy/ppruntime.h" #include "ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.h" -/* - * This is a whitelist of NaCl IRT interfaces that are exposed under - * PNaCl. This list omits the following: - * - * * The old versions of "irt-memory", v0.1 and v0.2, which contain - * the deprecated sysbrk() function. See: - * https://code.google.com/p/nativeclient/issues/detail?id=3542 - * - * * "irt-mutex", "irt-cond" and "irt-sem", which are deprecated and - * are superseded by the "irt-futex" interface. See: - * https://code.google.com/p/nativeclient/issues/detail?id=3484 - * - * * "irt-dyncode", which is not supported under PNaCl because - * dynamically loading architecture-specific native code is not - * portable. - * - * * "irt-exception-handling", which is not supported under PNaCl - * because it exposes non-portable, architecture-specific register - * state. See: - * https://code.google.com/p/nativeclient/issues/detail?id=3444 - * - * * "irt-blockhook", which is deprecated. It was provided for - * implementing thread suspension for conservative garbage - * collection, but this is probably not a portable use case under - * PNaCl, so this interface is disabled under PNaCl. See: - * https://code.google.com/p/nativeclient/issues/detail?id=3539 - * - * * "irt-resource-open". This was primarily provided for use by - * nacl-glibc's dynamic linker, which is not supported under PNaCl. - * open_resource() returns a file descriptor, but it is the only - * interface in NaCl to do so inside Chromium. This is - * inconsistent with PPAPI, which does not expose file descriptors - * (except in private/dev interfaces). See: - * https://code.google.com/p/nativeclient/issues/detail?id=3574 - * - * * "irt-fdio" and "irt-filename". Under PNaCl, where - * open_resource() open is disallowed, these are only useful for - * debugging. They are only allowed via the "dev" query strings; - * the non-"dev" query strings are disallowed. - * - * We omit these because they are only "dev" interfaces: - * - * * "irt-dev-getpid" - * * "irt-dev-list-mappings" - */ -static const char *const irt_interface_whitelist[] = { - NACL_IRT_BASIC_v0_1, - NACL_IRT_MEMORY_v0_3, - NACL_IRT_THREAD_v0_1, - NACL_IRT_FUTEX_v0_1, - NACL_IRT_TLS_v0_1, - NACL_IRT_PPAPIHOOK_v0_1, - NACL_IRT_RANDOM_v0_1, - NACL_IRT_CLOCK_v0_1, - /* Allowed for debugging purposes: */ - NACL_IRT_DEV_FDIO_v0_1, - NACL_IRT_DEV_FILENAME_v0_2, -}; - /* Use local strcmp to avoid dependency on libc. */ static int mystrcmp(const char* s1, const char *s2) { while((*s1 && *s2) && (*s1++ == *s2++)); return *(--s1) - *(--s2); } -static int is_irt_interface_whitelisted(const char *interface_name) { - int i; - for (i = 0; i < NACL_ARRAY_SIZE(irt_interface_whitelist); i++) { - if (mystrcmp(interface_name, irt_interface_whitelist[i]) == 0) { - return 1; - } - } - return 0; -} - TYPE_nacl_irt_query __pnacl_real_irt_interface = NULL; /* @@ -139,9 +68,6 @@ static int wrap_ppapi_start(const struct PP_StartFunctions *funcs) { size_t __pnacl_irt_interface_wrapper(const char *interface_ident, void *table, size_t tablesize) { - if (!is_irt_interface_whitelisted(interface_ident)) - return 0; - /* * Note there is a benign race in initializing the wrapper. * We build the "hook" structure by copying from the IRT's hook and then