[go: nahoru, domu]

Maximize RLIMIT_AS resource limit in nacl_helper child before exec

NaCl processes need an unusually large amount of address space, because
they do huge PROT_NONE mappings to reserve contiguous regions much larger
than the memory that will actually be used.  An ambient RLIMIT_AS setting
can break this, so we need to raise the soft limit to the hard limit (which
is usually unlimited).

We cannot rely on doing this inside the nacl_helper child itself, so we
must do it in the zygote before it exec's nacl_helper_bootstrap.  That exec
itself could fail if the limit is too small, because nacl_helper_bootstrap
uses ELF program headers to reserve a large region of address space.

BUG= http://code.google.com/p/nativeclient/issues/detail?id=2438
TEST= nacl apps work when "ulimit -S -v 5376320" was run before starting chrome

R=mark@chromium.org,bsy@google.com,bradchen@google.com

Review URL: http://codereview.chromium.org/8528041

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110123 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/process_util.h b/base/process_util.h
index fe2ad81d..fb2eb44 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -31,6 +31,7 @@
 #endif
 
 #include <list>
+#include <set>
 #include <string>
 #include <utility>
 #include <vector>
@@ -219,7 +220,8 @@
                     start_hidden(false), inherit_handles(false), as_user(NULL),
                     empty_desktop_name(false), job_handle(NULL)
 #else
-                    environ(NULL), fds_to_remap(NULL), new_process_group(false)
+                    environ(NULL), fds_to_remap(NULL), maximize_rlimits(NULL),
+                    new_process_group(false)
 #if defined(OS_LINUX)
                   , clone_flags(0)
 #endif  // OS_LINUX
@@ -265,6 +267,11 @@
   // call to LaunchProcess().
   const file_handle_mapping_vector* fds_to_remap;
 
+  // Each element is an RLIMIT_* constant that should be raised to its
+  // rlim_max.  This pointer is owned by the caller and must live through
+  // the call to LaunchProcess().
+  const std::set<int>* maximize_rlimits;
+
   // If true, start the process in a new process group, instead of
   // inheriting the parent's process group.  The pgid of the child process
   // will be the same as its pid.