Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2013 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 | |
| 7 /* | |
| 8 * Assume 32-byte trampoline slots, 16-byte bundles. | |
| 9 */ | |
| 10 #define GETTIMEOFDAY_ADDR 0x10500 | |
| 11 #define STORE_MASK $t7 | |
| 12 #define JUMP_MASK $t6 | |
| 13 | |
| 14 .data | |
| 15 timebuf: | |
| 16 .space 0x200 /* enough for a timeval */ | |
| 17 .text | |
| 18 .globl SyscallReturnIsSandboxed | |
| 19 SyscallReturnIsSandboxed: | |
| 20 .set noreorder | |
| 21 | |
| 22 addiu $sp, $sp, -24 | |
| 23 and $sp, $sp, STORE_MASK | |
| 24 sw $ra, 20($sp) | |
| 25 lui $a0, %hi(timebuf) | |
| 26 | |
| 27 addiu $a0, $a0, %lo(timebuf) | |
| 28 addu $a1, $zero, $zero | |
| 29 lui $ra, %hi(bad) | |
| 30 addiu $ra, $ra, %lo(bad) | |
| 31 | |
| 32 lui $a2, %hi(GETTIMEOFDAY_ADDR) | |
| 33 addiu $a2, $a2, %lo(GETTIMEOFDAY_ADDR) | |
| 34 and $a2, $a2, JUMP_MASK | |
| 35 jr $a2 | |
| 36 | |
| 37 nop /* sandboxed (bundle aligned) return address */ | |
|
Mark Seaborn
2013/03/12 00:39:29
This would be more robust as:
.p2align 4
/* Exp
| |
| 38 xor $v0, $v0, 1 /* expected return value */ | |
| 39 bad: lw $ra, 20($sp) /* non-sandboxed return address */ | |
| 40 nop | |
| 41 | |
| 42 addiu $sp, $sp, 24 | |
| 43 and $sp, $sp, STORE_MASK | |
| 44 and $ra, $ra, JUMP_MASK | |
| 45 jr $ra | |
| 46 | |
| 47 nop | |
| 48 | |
| OLD | NEW |