OLD | NEW |
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 #if defined(__NR_sigaction) | 10 #if defined(__NR_sigaction) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 #endif | 92 #endif |
93 | 93 |
94 #if defined(__NR_signal) | 94 #if defined(__NR_signal) |
95 void* Sandbox::sandbox_signal(int signum, const void* handler) { | 95 void* Sandbox::sandbox_signal(int signum, const void* handler) { |
96 struct kernel_old_sigaction sa, osa; | 96 struct kernel_old_sigaction sa, osa; |
97 sa.sa_handler_ = (void (*)(int))(handler); | 97 sa.sa_handler_ = (void (*)(int))(handler); |
98 sa.sa_flags = SA_NODEFER | SA_RESETHAND | SA_RESTORER; | 98 sa.sa_flags = SA_NODEFER | SA_RESETHAND | SA_RESTORER; |
99 sa.sa_mask = 0; | 99 sa.sa_mask = 0; |
100 asm volatile( | 100 asm volatile( |
101 "lea 0f, %0\n" | 101 "call 1f\n" |
102 "jmp 1f\n" | |
103 "0:pop %%eax\n" | 102 "0:pop %%eax\n" |
104 "mov $119, %%eax\n" // __NR_sigreturn | 103 "mov $119, %%eax\n" // __NR_sigreturn |
105 "int $0x80\n" | 104 "int $0x80\n" |
106 "1:\n" | 105 "1:pop %0\n" |
107 : "=r"(sa.sa_restorer)); | 106 : "=r"(sa.sa_restorer)); |
108 long rc = sandbox_sigaction(signum, &sa, &osa); | 107 long rc = sandbox_sigaction(signum, &sa, &osa); |
109 if (rc < 0) { | 108 if (rc < 0) { |
110 return (void *)rc; | 109 return (void *)rc; |
111 } | 110 } |
112 return reinterpret_cast<void *>(osa.sa_handler_); | 111 return reinterpret_cast<void *>(osa.sa_handler_); |
113 } | 112 } |
114 #endif | 113 #endif |
115 | 114 |
116 bool Sandbox::process_sigaction(const SyscallRequestInfo* info) { | 115 bool Sandbox::process_sigaction(const SyscallRequestInfo* info) { |
(...skipping 24 matching lines...) Expand all Loading... |
141 } | 140 } |
142 SecureMem::sendSystemCall(*info, SecureMem::SEND_UNLOCKED, | 141 SecureMem::sendSystemCall(*info, SecureMem::SEND_UNLOCKED, |
143 sigaction_req.signum, | 142 sigaction_req.signum, |
144 const_cast<SysCalls::kernel_sigaction*>(sigaction_req.action), | 143 const_cast<SysCalls::kernel_sigaction*>(sigaction_req.action), |
145 const_cast<SysCalls::kernel_sigaction*>(sigaction_req.old_action), | 144 const_cast<SysCalls::kernel_sigaction*>(sigaction_req.old_action), |
146 sigaction_req.sigsetsize); | 145 sigaction_req.sigsetsize); |
147 return true; | 146 return true; |
148 } | 147 } |
149 | 148 |
150 } // namespace | 149 } // namespace |
OLD | NEW |