sigsys_handlers.h revision 46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd
1// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef SANDBOX_LINUX_SECCOMP_BPF_HELPERS_SIGSYS_HANDLERS_H_ 6#define SANDBOX_LINUX_SECCOMP_BPF_HELPERS_SIGSYS_HANDLERS_H_ 7 8#include "base/basictypes.h" 9#include "build/build_config.h" 10#include "sandbox/sandbox_export.h" 11 12// The handlers are suitable for use in Trap() error codes. They are 13// guaranteed to be async-signal safe. 14// See sandbox/linux/seccomp-bpf/trap.h to see how they work. 15 16namespace sandbox { 17 18struct arch_seccomp_data; 19 20// This handler will crash the currently running process. The crashing address 21// will be the number of the current system call, extracted from |args|. 22// This handler will also print to stderr the number of the crashing syscall. 23SANDBOX_EXPORT intptr_t 24 CrashSIGSYS_Handler(const struct arch_seccomp_data& args, void* aux); 25 26// The following three handlers are suitable to report failures with the 27// clone(), prctl() and ioctl() system calls respectively. 28 29// The crashing address will be (clone_flags & 0xFFFFFF), where clone_flags is 30// the clone(2) argument, extracted from |args|. 31SANDBOX_EXPORT intptr_t 32 SIGSYSCloneFailure(const struct arch_seccomp_data& args, void* aux); 33// The crashing address will be (option & 0xFFF), where option is the prctl(2) 34// argument. 35SANDBOX_EXPORT intptr_t 36 SIGSYSPrctlFailure(const struct arch_seccomp_data& args, void* aux); 37// The crashing address will be request & 0xFFFF, where request is the ioctl(2) 38// argument. 39SANDBOX_EXPORT intptr_t 40 SIGSYSIoctlFailure(const struct arch_seccomp_data& args, void* aux); 41// The crashing address will be (pid & 0xFFF), where pid is the first 42// argument (and can be a tid). 43SANDBOX_EXPORT intptr_t 44 SIGSYSKillFailure(const struct arch_seccomp_data& args, void* aux); 45// The crashing address will be (op & 0xFFF), where op is the second 46// argument. 47SANDBOX_EXPORT intptr_t 48 SIGSYSFutexFailure(const struct arch_seccomp_data& args, void* aux); 49 50// Following four functions return substrings of error messages used 51// in the above four functions. They are useful in death tests. 52SANDBOX_EXPORT const char* GetErrorMessageContentForTests(); 53SANDBOX_EXPORT const char* GetCloneErrorMessageContentForTests(); 54SANDBOX_EXPORT const char* GetPrctlErrorMessageContentForTests(); 55SANDBOX_EXPORT const char* GetIoctlErrorMessageContentForTests(); 56SANDBOX_EXPORT const char* GetKillErrorMessageContentForTests(); 57SANDBOX_EXPORT const char* GetFutexErrorMessageContentForTests(); 58 59} // namespace sandbox. 60 61#endif // SANDBOX_LINUX_SECCOMP_BPF_HELPERS_SIGSYS_HANDLERS_H_ 62