Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(753)

Side by Side Diff: ipc/ipc_channel.cc

Issue 695353005: Non-SFI mode: Use dummy PID for NaCl's IPC channel on Linux platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_channel.h ('k') | ipc/ipc_channel_posix.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ipc/ipc_channel.h" 5 #include "ipc/ipc_channel.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 11 matching lines...) Expand all
22 // static 22 // static
23 std::string Channel::GenerateUniqueRandomChannelID() { 23 std::string Channel::GenerateUniqueRandomChannelID() {
24 // Note: the string must start with the current process id, this is how 24 // Note: the string must start with the current process id, this is how
25 // some child processes determine the pid of the parent. 25 // some child processes determine the pid of the parent.
26 // 26 //
27 // This is composed of a unique incremental identifier, the process ID of 27 // This is composed of a unique incremental identifier, the process ID of
28 // the creator, an identifier for the child instance, and a strong random 28 // the creator, an identifier for the child instance, and a strong random
29 // component. The strong random component prevents other processes from 29 // component. The strong random component prevents other processes from
30 // hijacking or squatting on predictable channel names. 30 // hijacking or squatting on predictable channel names.
31 31
32 #if defined(OS_LINUX) || defined(OS_NACL_NONSFI)
33 // On Linux platform, PID does not play any security role.
34 // In nacl_helper_nonsfi, the seccomp sandbox disallows the use of getpid().
35 // So, for both cases, we provide a dummy PID.
36 int process_id = -1;
37 #else
32 int process_id = base::GetCurrentProcId(); 38 int process_id = base::GetCurrentProcId();
39 #endif
33 return base::StringPrintf("%d.%u.%d", 40 return base::StringPrintf("%d.%u.%d",
34 process_id, 41 process_id,
35 g_last_id.GetNext(), 42 g_last_id.GetNext(),
36 base::RandInt(0, std::numeric_limits<int32>::max())); 43 base::RandInt(0, std::numeric_limits<int32>::max()));
37 } 44 }
38 45
39 } // namespace IPC 46 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_channel.h ('k') | ipc/ipc_channel_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698