Commit 171fa98d authored by mseaborn@chromium.org's avatar mseaborn@chromium.org

NaCl: Don't pass the NaCl process's Windows handle to the renderer process

The process handle is not used since we switched NaCl to using
Chromium's BrokerDuplicateHandle() function.

I have changed NaCl's SelLdrLauncher to not use the process ID or
process handle in this context, so returning dummy values of 0 and -1
will be OK: they will not get passed to kill(), waitpid() or
TerminateProcess().

BUG=http://code.google.com/p/nativeclient/issues/detail?id=2719
TEST=nacl_integration etc.


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133523 0039d316-1c4b-4281-b951-d872f2087c98
parent 3b2437b6
...@@ -910,44 +910,22 @@ bool NaClProcessHost::ReplyToRenderer() { ...@@ -910,44 +910,22 @@ bool NaClProcessHost::ReplyToRenderer() {
#endif #endif
} }
const ChildProcessData& data = process_->GetData();
base::ProcessHandle nacl_process_handle;
#if defined(OS_WIN) #if defined(OS_WIN)
// Copy the process handle into the renderer process.
// TODO(mseaborn): Remove this. The renderer process uses this
// handle with NaCl's handle_pass module, but we are replacing
// handle_pass with Chrome's BrokerDuplicateHandle() function.
if (!DuplicateHandle(base::GetCurrentProcessHandle(),
data.handle,
chrome_render_message_filter_->peer_handle(),
&nacl_process_handle,
PROCESS_DUP_HANDLE,
FALSE,
0)) {
DLOG(ERROR) << "DuplicateHandle() failed";
return false;
}
// If we are on 64-bit Windows, the NaCl process's sandbox is // If we are on 64-bit Windows, the NaCl process's sandbox is
// managed by a different process from the renderer's sandbox. We // managed by a different process from the renderer's sandbox. We
// need to inform the renderer's sandbox about the NaCl process so // need to inform the renderer's sandbox about the NaCl process so
// that the renderer can send handles to the NaCl process using // that the renderer can send handles to the NaCl process using
// BrokerDuplicateHandle(). // BrokerDuplicateHandle().
if (RunningOnWOW64()) { if (RunningOnWOW64()) {
if (!content::BrokerAddTargetPeer(data.handle)) { if (!content::BrokerAddTargetPeer(process_->GetData().handle)) {
DLOG(ERROR) << "Failed to add NaCl process PID"; DLOG(ERROR) << "Failed to add NaCl process PID";
return false; return false;
} }
} }
#else
// We use pid as process handle on Posix
nacl_process_handle = data.handle;
#endif #endif
// Get the pid of the NaCl process
base::ProcessId nacl_process_id = base::GetProcId(data.handle);
ChromeViewHostMsg_LaunchNaCl::WriteReplyParams( ChromeViewHostMsg_LaunchNaCl::WriteReplyParams(
reply_msg_, handles_for_renderer, nacl_process_handle, nacl_process_id); reply_msg_, handles_for_renderer);
chrome_render_message_filter_->Send(reply_msg_); chrome_render_message_filter_->Send(reply_msg_);
chrome_render_message_filter_ = NULL; chrome_render_message_filter_ = NULL;
reply_msg_ = NULL; reply_msg_ = NULL;
......
...@@ -483,13 +483,11 @@ IPC_MESSAGE_ROUTED3(ChromeViewHostMsg_ForwardMessageToExternalHost, ...@@ -483,13 +483,11 @@ IPC_MESSAGE_ROUTED3(ChromeViewHostMsg_ForwardMessageToExternalHost,
// A renderer sends this to the browser process when it wants to start // A renderer sends this to the browser process when it wants to start
// a new instance of the Native Client process. The browser will launch // a new instance of the Native Client process. The browser will launch
// the process and return a handle to an IMC channel. // the process and return a handle to an IMC channel.
IPC_SYNC_MESSAGE_CONTROL2_3(ChromeViewHostMsg_LaunchNaCl, IPC_SYNC_MESSAGE_CONTROL2_1(ChromeViewHostMsg_LaunchNaCl,
GURL /* manifest_url */, GURL /* manifest_url */,
int /* socket count */, int /* socket count */,
std::vector<nacl::FileDescriptor> std::vector<nacl::FileDescriptor>
/* imc channel handles */, /* imc channel handles */)
base::ProcessHandle /* NaCl process handle */,
base::ProcessId /* NaCl process id */)
// Notification that the page has an OpenSearch description document // Notification that the page has an OpenSearch description document
// associated with it. // associated with it.
......
...@@ -42,18 +42,13 @@ bool LaunchSelLdr(const char* alleged_url, int socket_count, ...@@ -42,18 +42,13 @@ bool LaunchSelLdr(const char* alleged_url, int socket_count,
void* imc_handles, void* nacl_process_handle, void* imc_handles, void* nacl_process_handle,
int* nacl_process_id) { int* nacl_process_id) {
std::vector<nacl::FileDescriptor> sockets; std::vector<nacl::FileDescriptor> sockets;
base::ProcessHandle nacl_process;
IPC::Message::Sender* sender = RenderThread::Get(); IPC::Message::Sender* sender = RenderThread::Get();
if (sender == NULL) { if (sender == NULL) {
sender = g_background_thread_sender.Pointer()->get(); sender = g_background_thread_sender.Pointer()->get();
} }
if (!sender->Send( if (!sender->Send(
new ChromeViewHostMsg_LaunchNaCl( new ChromeViewHostMsg_LaunchNaCl(
GURL(alleged_url), GURL(alleged_url), socket_count, &sockets))) {
socket_count,
&sockets,
&nacl_process,
reinterpret_cast<base::ProcessId*>(nacl_process_id)))) {
return false; return false;
} }
CHECK(static_cast<int>(sockets.size()) == socket_count); CHECK(static_cast<int>(sockets.size()) == socket_count);
...@@ -61,7 +56,11 @@ bool LaunchSelLdr(const char* alleged_url, int socket_count, ...@@ -61,7 +56,11 @@ bool LaunchSelLdr(const char* alleged_url, int socket_count,
static_cast<nacl::Handle*>(imc_handles)[i] = static_cast<nacl::Handle*>(imc_handles)[i] =
nacl::ToNativeHandle(sockets[i]); nacl::ToNativeHandle(sockets[i]);
} }
*static_cast<nacl::Handle*>(nacl_process_handle) = nacl_process; // TODO(mseaborn): Remove the arguments nacl_process_handle and
// nacl_process_id from the interface.
*reinterpret_cast<base::ProcessHandle*>(nacl_process_handle) =
(base::ProcessHandle) -1;
*nacl_process_id = 0;
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment