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

Side by Side Diff: sandbox/linux/seccomp/ipc.cc

Issue 997009: Compute and pring the time that it takes to execute system calls. This data... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « sandbox/linux/seccomp/ioctl.cc ('k') | sandbox/linux/seccomp/madvise.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "debug.h" 5 #include "debug.h"
6 #include "sandbox_impl.h" 6 #include "sandbox_impl.h"
7 7
8 namespace playground { 8 namespace playground {
9 9
10 #ifndef IPC_PRIVATE 10 #ifndef IPC_PRIVATE
11 #define IPC_PRIVATE 0 11 #define IPC_PRIVATE 0
12 #endif 12 #endif
13 #ifndef IPC_RMID 13 #ifndef IPC_RMID
14 #define IPC_RMID 0 14 #define IPC_RMID 0
15 #endif 15 #endif
16 #ifndef IPC_64 16 #ifndef IPC_64
17 #define IPC_64 256 17 #define IPC_64 256
18 #endif 18 #endif
19 19
20 #if defined(__NR_shmget) 20 #if defined(__NR_shmget)
21 void* Sandbox::sandbox_shmat(int shmid, const void* shmaddr, int shmflg) { 21 void* Sandbox::sandbox_shmat(int shmid, const void* shmaddr, int shmflg) {
22 Debug::syscall(__NR_shmat, "Executing handler"); 22 long long tm;
23 Debug::syscall(&tm, __NR_shmat, "Executing handler");
23 24
24 struct { 25 struct {
25 int sysnum; 26 int sysnum;
26 long long cookie; 27 long long cookie;
27 ShmAt shmat_req; 28 ShmAt shmat_req;
28 } __attribute__((packed)) request; 29 } __attribute__((packed)) request;
29 request.sysnum = __NR_shmat; 30 request.sysnum = __NR_shmat;
30 request.cookie = cookie(); 31 request.cookie = cookie();
31 request.shmat_req.shmid = shmid; 32 request.shmat_req.shmid = shmid;
32 request.shmat_req.shmaddr = shmaddr; 33 request.shmat_req.shmaddr = shmaddr;
33 request.shmat_req.shmflg = shmflg; 34 request.shmat_req.shmflg = shmflg;
34 35
35 long rc; 36 long rc;
36 SysCalls sys; 37 SysCalls sys;
37 if (write(sys, processFdPub(), &request, sizeof(request)) != 38 if (write(sys, processFdPub(), &request, sizeof(request)) !=
38 sizeof(request) || 39 sizeof(request) ||
39 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { 40 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) {
40 die("Failed to forward shmat() request [sandbox]"); 41 die("Failed to forward shmat() request [sandbox]");
41 } 42 }
43 Debug::elapsed(tm, __NR_shmat);
42 return reinterpret_cast<void *>(rc); 44 return reinterpret_cast<void *>(rc);
43 } 45 }
44 46
45 int Sandbox::sandbox_shmctl(int shmid, int cmd, void* buf) { 47 int Sandbox::sandbox_shmctl(int shmid, int cmd, void* buf) {
46 Debug::syscall(__NR_shmctl, "Executing handler"); 48 long long tm;
49 Debug::syscall(&tm, __NR_shmctl, "Executing handler");
47 50
48 struct { 51 struct {
49 int sysnum; 52 int sysnum;
50 long long cookie; 53 long long cookie;
51 ShmCtl shmctl_req; 54 ShmCtl shmctl_req;
52 } __attribute__((packed)) request; 55 } __attribute__((packed)) request;
53 request.sysnum = __NR_shmctl; 56 request.sysnum = __NR_shmctl;
54 request.cookie = cookie(); 57 request.cookie = cookie();
55 request.shmctl_req.shmid = shmid; 58 request.shmctl_req.shmid = shmid;
56 request.shmctl_req.cmd = cmd; 59 request.shmctl_req.cmd = cmd;
57 request.shmctl_req.buf = buf; 60 request.shmctl_req.buf = buf;
58 61
59 long rc; 62 long rc;
60 SysCalls sys; 63 SysCalls sys;
61 if (write(sys, processFdPub(), &request, sizeof(request)) != 64 if (write(sys, processFdPub(), &request, sizeof(request)) !=
62 sizeof(request) || 65 sizeof(request) ||
63 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { 66 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) {
64 die("Failed to forward shmctl() request [sandbox]"); 67 die("Failed to forward shmctl() request [sandbox]");
65 } 68 }
69 Debug::elapsed(tm, __NR_shmctl);
66 return static_cast<int>(rc); 70 return static_cast<int>(rc);
67 } 71 }
68 72
69 int Sandbox::sandbox_shmdt(const void* shmaddr) { 73 int Sandbox::sandbox_shmdt(const void* shmaddr) {
70 Debug::syscall(__NR_shmdt, "Executing handler"); 74 long long tm;
75 Debug::syscall(&tm, __NR_shmdt, "Executing handler");
71 76
72 struct { 77 struct {
73 int sysnum; 78 int sysnum;
74 long long cookie; 79 long long cookie;
75 ShmDt shmdt_req; 80 ShmDt shmdt_req;
76 } __attribute__((packed)) request; 81 } __attribute__((packed)) request;
77 request.sysnum = __NR_shmdt; 82 request.sysnum = __NR_shmdt;
78 request.cookie = cookie(); 83 request.cookie = cookie();
79 request.shmdt_req.shmaddr = shmaddr; 84 request.shmdt_req.shmaddr = shmaddr;
80 85
81 long rc; 86 long rc;
82 SysCalls sys; 87 SysCalls sys;
83 if (write(sys, processFdPub(), &request, sizeof(request)) != 88 if (write(sys, processFdPub(), &request, sizeof(request)) !=
84 sizeof(request) || 89 sizeof(request) ||
85 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { 90 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) {
86 die("Failed to forward shmdt() request [sandbox]"); 91 die("Failed to forward shmdt() request [sandbox]");
87 } 92 }
93 Debug::elapsed(tm, __NR_shmdt);
88 return static_cast<int>(rc); 94 return static_cast<int>(rc);
89 } 95 }
90 96
91 int Sandbox::sandbox_shmget(int key, size_t size, int shmflg) { 97 int Sandbox::sandbox_shmget(int key, size_t size, int shmflg) {
92 Debug::syscall(__NR_shmget, "Executing handler"); 98 long long tm;
99 Debug::syscall(&tm, __NR_shmget, "Executing handler");
93 100
94 struct { 101 struct {
95 int sysnum; 102 int sysnum;
96 long long cookie; 103 long long cookie;
97 ShmGet shmget_req; 104 ShmGet shmget_req;
98 } __attribute__((packed)) request; 105 } __attribute__((packed)) request;
99 request.sysnum = __NR_shmget; 106 request.sysnum = __NR_shmget;
100 request.cookie = cookie(); 107 request.cookie = cookie();
101 request.shmget_req.key = key; 108 request.shmget_req.key = key;
102 request.shmget_req.size = size; 109 request.shmget_req.size = size;
103 request.shmget_req.shmflg = shmflg; 110 request.shmget_req.shmflg = shmflg;
104 111
105 long rc; 112 long rc;
106 SysCalls sys; 113 SysCalls sys;
107 if (write(sys, processFdPub(), &request, sizeof(request)) != 114 if (write(sys, processFdPub(), &request, sizeof(request)) !=
108 sizeof(request) || 115 sizeof(request) ||
109 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { 116 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) {
110 die("Failed to forward shmget() request [sandbox]"); 117 die("Failed to forward shmget() request [sandbox]");
111 } 118 }
119 Debug::elapsed(tm, __NR_shmget);
112 return static_cast<int>(rc); 120 return static_cast<int>(rc);
113 } 121 }
114 122
115 bool Sandbox::process_shmat(int parentMapsFd, int sandboxFd, int threadFdPub, 123 bool Sandbox::process_shmat(int parentMapsFd, int sandboxFd, int threadFdPub,
116 int threadFd, SecureMem::Args* mem) { 124 int threadFd, SecureMem::Args* mem) {
117 // Read request 125 // Read request
118 ShmAt shmat_req; 126 ShmAt shmat_req;
119 SysCalls sys; 127 SysCalls sys;
120 if (read(sys, sandboxFd, &shmat_req, sizeof(shmat_req)) != 128 if (read(sys, sandboxFd, &shmat_req, sizeof(shmat_req)) !=
121 sizeof(shmat_req)) { 129 sizeof(shmat_req)) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 #endif 241 #endif
234 #ifndef SHMGET 242 #ifndef SHMGET
235 #define SHMGET 23 243 #define SHMGET 23
236 #endif 244 #endif
237 #ifndef SHMCTL 245 #ifndef SHMCTL
238 #define SHMCTL 24 246 #define SHMCTL 24
239 #endif 247 #endif
240 248
241 int Sandbox::sandbox_ipc(unsigned call, int first, int second, int third, 249 int Sandbox::sandbox_ipc(unsigned call, int first, int second, int third,
242 void* ptr, long fifth) { 250 void* ptr, long fifth) {
243 Debug::syscall(__NR_ipc, "Executing handler", call); 251 long long tm;
252 Debug::syscall(&tm, __NR_ipc, "Executing handler", call);
244 struct { 253 struct {
245 int sysnum; 254 int sysnum;
246 long long cookie; 255 long long cookie;
247 IPC ipc_req; 256 IPC ipc_req;
248 } __attribute__((packed)) request; 257 } __attribute__((packed)) request;
249 request.sysnum = __NR_ipc; 258 request.sysnum = __NR_ipc;
250 request.cookie = cookie(); 259 request.cookie = cookie();
251 request.ipc_req.call = call; 260 request.ipc_req.call = call;
252 request.ipc_req.first = first; 261 request.ipc_req.first = first;
253 request.ipc_req.second = second; 262 request.ipc_req.second = second;
254 request.ipc_req.third = third; 263 request.ipc_req.third = third;
255 request.ipc_req.ptr = ptr; 264 request.ipc_req.ptr = ptr;
256 request.ipc_req.fifth = fifth; 265 request.ipc_req.fifth = fifth;
257 266
258 long rc; 267 long rc;
259 SysCalls sys; 268 SysCalls sys;
260 if (write(sys, processFdPub(), &request, sizeof(request)) != 269 if (write(sys, processFdPub(), &request, sizeof(request)) !=
261 sizeof(request) || 270 sizeof(request) ||
262 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { 271 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) {
263 die("Failed to forward ipc() request [sandbox]"); 272 die("Failed to forward ipc() request [sandbox]");
264 } 273 }
274 Debug::elapsed(tm, __NR_ipc, call);
265 return static_cast<int>(rc); 275 return static_cast<int>(rc);
266 } 276 }
267 277
268 bool Sandbox::process_ipc(int parentMapsFd, int sandboxFd, int threadFdPub, 278 bool Sandbox::process_ipc(int parentMapsFd, int sandboxFd, int threadFdPub,
269 int threadFd, SecureMem::Args* mem) { 279 int threadFd, SecureMem::Args* mem) {
270 // Read request 280 // Read request
271 IPC ipc_req; 281 IPC ipc_req;
272 SysCalls sys; 282 SysCalls sys;
273 if (read(sys, sandboxFd, &ipc_req, sizeof(ipc_req)) != sizeof(ipc_req)) { 283 if (read(sys, sandboxFd, &ipc_req, sizeof(ipc_req)) != sizeof(ipc_req)) {
274 die("Failed to read parameters for ipc() [process]"); 284 die("Failed to read parameters for ipc() [process]");
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 // other SysV IPC calls. 342 // other SysV IPC calls.
333 deny: 343 deny:
334 mem->shmId = -1; 344 mem->shmId = -1;
335 SecureMem::abandonSystemCall(threadFd, -EINVAL); 345 SecureMem::abandonSystemCall(threadFd, -EINVAL);
336 return false; 346 return false;
337 } 347 }
338 } 348 }
339 #endif 349 #endif
340 350
341 } // namespace 351 } // namespace
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp/ioctl.cc ('k') | sandbox/linux/seccomp/madvise.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698