| Index: content/browser/renderer_host/sandbox_ipc_linux.cc
|
| diff --git a/content/browser/renderer_host/sandbox_ipc_linux.cc b/content/browser/renderer_host/sandbox_ipc_linux.cc
|
| index ad1747e01736ec41d009c825a9562f8b3b8708d0..aec32c0e9c6a290f606b00503ec43c331d0afa4f 100644
|
| --- a/content/browser/renderer_host/sandbox_ipc_linux.cc
|
| +++ b/content/browser/renderer_host/sandbox_ipc_linux.cc
|
| @@ -158,6 +158,9 @@ void SandboxIPCProcess::Run() {
|
| pfds[1].fd = browser_socket_;
|
| pfds[1].events = POLLIN;
|
|
|
| + if (!UnixDomainSocket::EnableReceiveProcessId(browser_socket_))
|
| + LOG(FATAL) << "failed to enable receiving PIDs";
|
| +
|
| int failed_polls = 0;
|
| for (;;) {
|
| const int r = HANDLE_EINTR(poll(pfds, 2, -1 /* no timeout */));
|
| @@ -187,6 +190,7 @@ void SandboxIPCProcess::Run() {
|
|
|
| void SandboxIPCProcess::HandleRequestFromRenderer(int fd) {
|
| std::vector<int> fds;
|
| + base::ProcessId sender_pid;
|
|
|
| // A FontConfigIPC::METHOD_MATCH message could be kMaxFontFamilyLength
|
| // bytes long (this is the largest message type).
|
| @@ -194,7 +198,8 @@ void SandboxIPCProcess::HandleRequestFromRenderer(int fd) {
|
| // error for a maximum length message.
|
| char buf[FontConfigIPC::kMaxFontFamilyLength + 128];
|
|
|
| - const ssize_t len = UnixDomainSocket::RecvMsg(fd, buf, sizeof(buf), &fds);
|
| + const ssize_t len =
|
| + UnixDomainSocket::RecvMsgWithPid(fd, buf, sizeof(buf), &fds, &sender_pid);
|
| if (len == -1) {
|
| // TODO: should send an error reply, or the sender might block forever.
|
| NOTREACHED() << "Sandbox host message is larger than kMaxFontFamilyLength";
|
| @@ -226,6 +231,8 @@ void SandboxIPCProcess::HandleRequestFromRenderer(int fd) {
|
| HandleMakeSharedMemorySegment(fd, pickle, iter, fds);
|
| } else if (kind == LinuxSandbox::METHOD_MATCH_WITH_FALLBACK) {
|
| HandleMatchWithFallback(fd, pickle, iter, fds);
|
| + } else if (kind == LinuxSandbox::METHOD_GET_REAL_PID) {
|
| + HandleGetRealPid(fd, pickle, iter, fds, sender_pid);
|
| }
|
|
|
| error:
|
| @@ -613,6 +620,29 @@ void SandboxIPCProcess::HandleMatchWithFallback(int fd,
|
| }
|
| }
|
|
|
| +void SandboxIPCProcess::HandleGetRealPid(int fd,
|
| + const Pickle& pickle,
|
| + PickleIterator iter,
|
| + std::vector<int>& fds,
|
| + base::ProcessId sender_pid) {
|
| + if (fds.size() != 2)
|
| + return;
|
| +
|
| + bool return_pid;
|
| + if (!iter.ReadBool(&return_pid))
|
| + return;
|
| +
|
| + // Write it to the zygote process.
|
| + const ssize_t written =
|
| + HANDLE_EINTR(write(fds[1], &sender_pid, sizeof(sender_pid)));
|
| + if (written != sizeof(sender_pid))
|
| + LOG(ERROR) << "Failed to write real pid to zygote";
|
| +
|
| + Pickle reply;
|
| + reply.WriteInt(return_pid ? sender_pid : 0);
|
| + SendRendererReply(fds, reply, -1);
|
| +}
|
| +
|
| void SandboxIPCProcess::SendRendererReply(const std::vector<int>& fds,
|
| const Pickle& reply,
|
| int reply_fd) {
|
|
|