OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. |
| 5 */ |
| 6 #include <string.h> |
| 7 |
| 8 #include "native_client/src/include/minsfi_priv.h" |
| 9 |
| 10 /* |
| 11 * This is the memory base variable which the SFI-sandboxed pointers are |
| 12 * treated relative to. It is defined in the trusted runtime, exported and then |
| 13 * imported by the untrusted code via the compiler transforms. It is a 64-bit |
| 14 * unsigned integer on both 32-bit and 64-bit platforms. See comments in the |
| 15 * SandboxMemoryAccesses MinSFI LLVM pass for more details. |
| 16 */ |
| 17 uint64_t __sfi_memory_base = 0; |
| 18 |
| 19 static MinsfiSandbox ActiveSandbox = { .mem_base = NULL }; |
| 20 |
| 21 const MinsfiSandbox *MinsfiGetActiveSandbox(void) { |
| 22 if (ActiveSandbox.mem_base != NULL) |
| 23 return &ActiveSandbox; |
| 24 else |
| 25 return NULL; |
| 26 } |
| 27 |
| 28 void MinsfiSetActiveSandbox(const MinsfiSandbox *sb) { |
| 29 if (sb != NULL) |
| 30 memcpy(&ActiveSandbox, sb, sizeof(MinsfiSandbox)); |
| 31 else |
| 32 ActiveSandbox.mem_base = NULL; |
| 33 |
| 34 __sfi_memory_base = (uintptr_t) ActiveSandbox.mem_base; |
| 35 } |
OLD | NEW |