diff options
author | mdempsky@chromium.org <mdempsky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-01 07:42:11 +0000 |
---|---|---|
committer | mdempsky@chromium.org <mdempsky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-01 07:42:11 +0000 |
commit | 36f8ffcd2da5db7d77858ac5ed35761d4cba4c3d (patch) | |
tree | 8bb792b5dae44aea8d0b698af653214e81037297 | |
parent | 185de3da290307563a519bc12d922951ece7a8be (diff) | |
download | chromium_src-36f8ffcd2da5db7d77858ac5ed35761d4cba4c3d.zip chromium_src-36f8ffcd2da5db7d77858ac5ed35761d4cba4c3d.tar.gz chromium_src-36f8ffcd2da5db7d77858ac5ed35761d4cba4c3d.tar.bz2 |
Annotate IA-32's SyscallAsm implementation with CFI directives
This is necessary so that glibc's backtrace() routine can properly unwind
the stack when called within a Trap handler triggered by Syscall::Call().
Otherwise the .eh_frame data will mislead backtrace() into thinking %ebp is
still valid, when we've actually clobbered it with a syscall parameter.
This allows us to also enable the InvalidSyscall BPF tests on IA-32.
BUG=399396
Review URL: https://codereview.chromium.org/430353002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286959 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc | 3 | ||||
-rw-r--r-- | sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc | 3 | ||||
-rw-r--r-- | sandbox/linux/seccomp-bpf/syscall.cc | 16 |
3 files changed, 8 insertions, 14 deletions
diff --git a/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc b/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc index bfa1689..1c896cc 100644 --- a/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc +++ b/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc @@ -483,15 +483,12 @@ BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, clock_gettime(kInitCPUClockID, &ts); } -// TODO(mdempsky): Enable on IA-32 after fixing crbug.com/399396. -#if !defined(__i386__) BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, invalid_syscall_crash, DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { sandbox::Syscall::InvalidCall(); } -#endif // The following test cases check if syscalls return EPERM regardless // of arguments. diff --git a/sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc b/sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc index fdcb232..d1899c3 100644 --- a/sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc +++ b/sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc @@ -209,15 +209,12 @@ BPF_TEST_C(BaselinePolicy, EPERM_getcwd, BaselinePolicy) { BPF_ASSERT_EQ(EPERM, errno); } -// TODO(mdempsky): Enable on IA-32 after fixing crbug.com/399396. -#if !defined(__i386__) BPF_DEATH_TEST_C(BaselinePolicy, SIGSYS_InvalidSyscall, DEATH_SEGV_MESSAGE(GetErrorMessageContentForTests()), BaselinePolicy) { Syscall::InvalidCall(); } -#endif // A failing test using this macro could be problematic since we perform // system calls by passing "0" as every argument. diff --git a/sandbox/linux/seccomp-bpf/syscall.cc b/sandbox/linux/seccomp-bpf/syscall.cc index eacaabd..b0a41b0 100644 --- a/sandbox/linux/seccomp-bpf/syscall.cc +++ b/sandbox/linux/seccomp-bpf/syscall.cc @@ -59,10 +59,10 @@ asm(// We need to be able to tell the kernel exactly where we made a // that are used internally (e.g. %ebx for position-independent // code, and %ebp for the frame pointer), and as we need to keep at // least a few registers available for the register allocator. - "1:push %esi; .cfi_adjust_cfa_offset 4\n" - "push %edi; .cfi_adjust_cfa_offset 4\n" - "push %ebx; .cfi_adjust_cfa_offset 4\n" - "push %ebp; .cfi_adjust_cfa_offset 4\n" + "1:push %esi; .cfi_adjust_cfa_offset 4; .cfi_rel_offset esi, 0\n" + "push %edi; .cfi_adjust_cfa_offset 4; .cfi_rel_offset edi, 0\n" + "push %ebx; .cfi_adjust_cfa_offset 4; .cfi_rel_offset ebx, 0\n" + "push %ebp; .cfi_adjust_cfa_offset 4; .cfi_rel_offset ebp, 0\n" // Copy entries from the array holding the arguments into the // correct CPU registers. "movl 0(%edi), %ebx\n" @@ -77,10 +77,10 @@ asm(// We need to be able to tell the kernel exactly where we made a "2:" // Restore any clobbered registers that we didn't declare to the // compiler. - "pop %ebp; .cfi_adjust_cfa_offset -4\n" - "pop %ebx; .cfi_adjust_cfa_offset -4\n" - "pop %edi; .cfi_adjust_cfa_offset -4\n" - "pop %esi; .cfi_adjust_cfa_offset -4\n" + "pop %ebp; .cfi_restore ebp; .cfi_adjust_cfa_offset -4\n" + "pop %ebx; .cfi_restore ebx; .cfi_adjust_cfa_offset -4\n" + "pop %edi; .cfi_restore edi; .cfi_adjust_cfa_offset -4\n" + "pop %esi; .cfi_restore esi; .cfi_adjust_cfa_offset -4\n" "ret\n" ".cfi_endproc\n" "9:.size SyscallAsm, 9b-SyscallAsm\n" |