OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "debug.h" | |
6 #include "sandbox_impl.h" | |
7 | |
8 namespace playground { | |
9 | |
10 long Sandbox::sandbox_ioctl(int d, int req, void *arg) { | |
11 long long tm; | |
12 Debug::syscall(&tm, __NR_ioctl, "Executing handler"); | |
13 struct { | |
14 int sysnum; | |
15 long long cookie; | |
16 IOCtl ioctl_req; | |
17 } __attribute__((packed)) request; | |
18 request.sysnum = __NR_ioctl; | |
19 request.cookie = cookie(); | |
20 request.ioctl_req.d = d; | |
21 request.ioctl_req.req = req; | |
22 request.ioctl_req.arg = arg; | |
23 | |
24 long rc; | |
25 SysCalls sys; | |
26 if (write(sys, processFdPub(), &request, sizeof(request)) != | |
27 sizeof(request) || | |
28 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { | |
29 die("Failed to forward ioctl() request [sandbox]"); | |
30 } | |
31 Debug::elapsed(tm, __NR_ioctl); | |
32 return rc; | |
33 } | |
34 | |
35 bool Sandbox::process_ioctl(int parentMapsFd, int sandboxFd, int threadFdPub, | |
36 int threadFd, SecureMem::Args* mem) { | |
37 // Read request | |
38 IOCtl ioctl_req; | |
39 SysCalls sys; | |
40 if (read(sys, sandboxFd, &ioctl_req, sizeof(ioctl_req)) !=sizeof(ioctl_req)){ | |
41 die("Failed to read parameters for ioctl() [process]"); | |
42 } | |
43 int rc = -EINVAL; | |
44 switch (ioctl_req.req) { | |
45 case TCGETS: | |
46 case TIOCGWINSZ: | |
47 SecureMem::sendSystemCall(threadFdPub, false, -1, mem, __NR_ioctl, | |
48 ioctl_req.d, ioctl_req.req, ioctl_req.arg); | |
49 return true; | |
50 default: | |
51 if (Debug::isEnabled()) { | |
52 char buf[80]; | |
53 sprintf(buf, "Unsupported ioctl: 0x%04X\n", ioctl_req.req); | |
54 Debug::message(buf); | |
55 } | |
56 SecureMem::abandonSystemCall(threadFd, rc); | |
57 return false; | |
58 } | |
59 } | |
60 | |
61 } // namespace | |
OLD | NEW |