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 #ifndef SECURE_MEM_H__ | 5 #ifndef SECURE_MEM_H__ |
6 #define SECURE_MEM_H__ | 6 #define SECURE_MEM_H__ |
7 | 7 |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include "linux_syscall_support.h" | 9 #include "linux_syscall_support.h" |
10 | 10 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // of safety, e.g. for thread exit. | 161 // of safety, e.g. for thread exit. |
162 SEND_LOCKED_SYNC, | 162 SEND_LOCKED_SYNC, |
163 }; | 163 }; |
164 | 164 |
165 // Sends a system call to the trusted thread for execution. | 165 // Sends a system call to the trusted thread for execution. |
166 static void sendSystemCall(const SyscallRequestInfo& rpc, LockType type) { | 166 static void sendSystemCall(const SyscallRequestInfo& rpc, LockType type) { |
167 sendSystemCallInternal(rpc, type); | 167 sendSystemCallInternal(rpc, type); |
168 } | 168 } |
169 template<class T1> static | 169 template<class T1> static |
170 void sendSystemCall(const SyscallRequestInfo& rpc, LockType type, T1 arg1) { | 170 void sendSystemCall(const SyscallRequestInfo& rpc, LockType type, T1 arg1) { |
171 sendSystemCallInternal(rpc, type, (void*)arg1); | 171 sendSystemCallInternal(rpc, type, reinterpret_cast<void*>(arg1)); |
172 } | 172 } |
173 template<class T1, class T2> static | 173 template<class T1, class T2> static |
174 void sendSystemCall(const SyscallRequestInfo& rpc, LockType type, | 174 void sendSystemCall(const SyscallRequestInfo& rpc, LockType type, |
175 T1 arg1, T2 arg2) { | 175 T1 arg1, T2 arg2) { |
176 sendSystemCallInternal(rpc, type, (void*)arg1, (void*)arg2); | 176 sendSystemCallInternal(rpc, type, reinterpret_cast<void*>(arg1), |
| 177 reinterpret_cast<void*>(arg2)); |
177 } | 178 } |
178 template<class T1, class T2, class T3> static | 179 template<class T1, class T2, class T3> static |
179 void sendSystemCall(const SyscallRequestInfo& rpc, LockType type, | 180 void sendSystemCall(const SyscallRequestInfo& rpc, LockType type, |
180 T1 arg1, T2 arg2, T3 arg3) { | 181 T1 arg1, T2 arg2, T3 arg3) { |
181 sendSystemCallInternal(rpc, type, (void*)arg1, (void*)arg2, (void*)arg3); | 182 sendSystemCallInternal(rpc, type, reinterpret_cast<void*>(arg1), |
| 183 reinterpret_cast<void*>(arg2), |
| 184 reinterpret_cast<void*>(arg3)); |
182 } | 185 } |
183 template<class T1, class T2, class T3, class T4> static | 186 template<class T1, class T2, class T3, class T4> static |
184 void sendSystemCall(const SyscallRequestInfo& rpc, LockType type, | 187 void sendSystemCall(const SyscallRequestInfo& rpc, LockType type, |
185 T1 arg1, T2 arg2, T3 arg3, T4 arg4) { | 188 T1 arg1, T2 arg2, T3 arg3, T4 arg4) { |
186 sendSystemCallInternal(rpc, type, (void*)arg1, (void*)arg2, (void*)arg3, | 189 sendSystemCallInternal(rpc, type, reinterpret_cast<void*>(arg1), |
187 (void*)arg4); | 190 reinterpret_cast<void*>(arg2), |
| 191 reinterpret_cast<void*>(arg3), |
| 192 reinterpret_cast<void*>(arg4)); |
188 } | 193 } |
189 template<class T1, class T2, class T3, class T4, class T5> static | 194 template<class T1, class T2, class T3, class T4, class T5> static |
190 void sendSystemCall(const SyscallRequestInfo& rpc, LockType type, | 195 void sendSystemCall(const SyscallRequestInfo& rpc, LockType type, |
191 T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { | 196 T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { |
192 sendSystemCallInternal(rpc, type, (void*)arg1, (void*)arg2, (void*)arg3, | 197 sendSystemCallInternal(rpc, type, reinterpret_cast<void*>(arg1), |
193 (void*)arg4, (void*)arg5); | 198 reinterpret_cast<void*>(arg2), |
| 199 reinterpret_cast<void*>(arg3), |
| 200 reinterpret_cast<void*>(arg4), |
| 201 reinterpret_cast<void*>(arg5)); |
194 } | 202 } |
195 template<class T1, class T2, class T3, class T4, class T5, class T6> static | 203 template<class T1, class T2, class T3, class T4, class T5, class T6> static |
196 void sendSystemCall(const SyscallRequestInfo& rpc, LockType type, | 204 void sendSystemCall(const SyscallRequestInfo& rpc, LockType type, |
197 T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, | 205 T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, |
198 Args* newSecureMem = 0) { | 206 Args* newSecureMem = 0) { |
199 sendSystemCallInternal(rpc, type, (void*)arg1, (void*)arg2, (void*)arg3, | 207 sendSystemCallInternal(rpc, type, reinterpret_cast<void*>(arg1), |
200 (void*)arg4, (void*)arg5, (void*)arg6, | 208 reinterpret_cast<void*>(arg2), |
201 newSecureMem); | 209 reinterpret_cast<void*>(arg3), |
| 210 reinterpret_cast<void*>(arg4), |
| 211 reinterpret_cast<void*>(arg5), |
| 212 reinterpret_cast<void*>(arg6), newSecureMem); |
202 } | 213 } |
203 | 214 |
204 private: | 215 private: |
205 // Allows the trusted process to check whether the parent process still | 216 // Allows the trusted process to check whether the parent process still |
206 // exists. If it doesn't, kill the trusted process. | 217 // exists. If it doesn't, kill the trusted process. |
207 static void dieIfParentDied(int parentMapsFd); | 218 static void dieIfParentDied(int parentMapsFd); |
208 | 219 |
209 static void sendSystemCallInternal(const SyscallRequestInfo& rpc, | 220 static void sendSystemCallInternal(const SyscallRequestInfo& rpc, |
210 LockType type, | 221 LockType type, |
211 void* arg1 = 0, void* arg2 = 0, | 222 void* arg1 = 0, void* arg2 = 0, |
212 void* arg3 = 0, void* arg4 = 0, | 223 void* arg3 = 0, void* arg4 = 0, |
213 void* arg5 = 0, void* arg6 = 0, | 224 void* arg5 = 0, void* arg6 = 0, |
214 Args* newSecureMem = 0); | 225 Args* newSecureMem = 0); |
215 }; | 226 }; |
216 | 227 |
217 } // namespace | 228 } // namespace |
218 | 229 |
219 #endif // SECURE_MEM_H__ | 230 #endif // SECURE_MEM_H__ |
OLD | NEW |