summaryrefslogtreecommitdiffstats
path: root/chrome/nacl
diff options
context:
space:
mode:
authorjln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-02 00:52:01 +0000
committerjln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-02 00:52:01 +0000
commitd9f2dc34dfecf6fa9500485a1f4af94073890ef3 (patch)
tree177da8b47f53ff9807a8217a5f14066ddc01a20f /chrome/nacl
parent601d80144bd7af3350a5396426953b5ff3bbe03f (diff)
downloadchromium_src-d9f2dc34dfecf6fa9500485a1f4af94073890ef3.zip
chromium_src-d9f2dc34dfecf6fa9500485a1f4af94073890ef3.tar.gz
chromium_src-d9f2dc34dfecf6fa9500485a1f4af94073890ef3.tar.bz2
Linux nacl_helper: make it clear when we get sandboxed
Make it more clear at what point the nacl_helper gets sandboxed via the Zygote. BUG=168812 NOTRY=true Review URL: https://chromiumcodereview.appspot.com/12385032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185638 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/nacl')
-rw-r--r--chrome/nacl/nacl_helper_linux.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/chrome/nacl/nacl_helper_linux.cc b/chrome/nacl/nacl_helper_linux.cc
index 2dbb950..53c2fb30 100644
--- a/chrome/nacl/nacl_helper_linux.cc
+++ b/chrome/nacl/nacl_helper_linux.cc
@@ -7,10 +7,12 @@
#include "chrome/common/nacl_helper_linux.h"
#include <errno.h>
+#include <fcntl.h>
#include <link.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include <string>
@@ -117,6 +119,16 @@ void HandleForkRequest(const std::vector<int>& child_fds,
}
}
+// This is a poor man's check on whether we are sandboxed.
+bool IsSandboxed() {
+ int proc_fd = open("/proc/self/exe", O_RDONLY);
+ if (proc_fd >= 0) {
+ HANDLE_EINTR(close(proc_fd));
+ return false;
+ }
+ return true;
+}
+
} // namespace
static const char kNaClHelperReservedAtZero[] = "reserved_at_zero";
@@ -227,6 +239,9 @@ int main(int argc, char* argv[]) {
CheckRDebug(argv[0]);
+ // Check that IsSandboxed() works. We should not be sandboxed at this point.
+ CHECK(!IsSandboxed()) << "Unexpectedly sandboxed!";
+
// Send the zygote a message to let it know we are ready to help
if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor,
kNaClHelperStartupAck,
@@ -241,6 +256,13 @@ int main(int argc, char* argv[]) {
char buf[kMaxMessageLength];
const ssize_t msglen = UnixDomainSocket::RecvMsg(kNaClZygoteDescriptor,
&buf, sizeof(buf), &fds);
+ // If the Zygote has started handling requests, we should be sandboxed via
+ // the setuid sandbox.
+ if (!IsSandboxed()) {
+ LOG(ERROR) << "NaCl helper process running without a sandbox!\n"
+ << "Most likely you need to configure your SUID sandbox "
+ << "correctly";
+ }
if (msglen == 0 || (msglen == -1 && errno == ECONNRESET)) {
// EOF from the browser. Goodbye!
_exit(0);