Skip to content

Commit

Permalink
NaCl: Remove PNaCl's IRT interface whitelist from the PNaCl IRT shims
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mseaborn@chromium.org committed Mar 8, 2014
1 parent 3bc1379 commit 23dad53
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 74 deletions.
5 changes: 5 additions & 0 deletions components/nacl/loader/nacl_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
74 changes: 0 additions & 74 deletions ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,88 +7,17 @@
#include "ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.h"

#include <string.h>
#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;

/*
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 23dad53

Please sign in to comment.