summaryrefslogtreecommitdiff
path: root/chromium/sandbox/linux/seccomp-bpf/die.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/sandbox/linux/seccomp-bpf/die.cc')
-rw-r--r--chromium/sandbox/linux/seccomp-bpf/die.cc35
1 files changed, 15 insertions, 20 deletions
diff --git a/chromium/sandbox/linux/seccomp-bpf/die.cc b/chromium/sandbox/linux/seccomp-bpf/die.cc
index dfc59a50e78..533e2e9c353 100644
--- a/chromium/sandbox/linux/seccomp-bpf/die.cc
+++ b/chromium/sandbox/linux/seccomp-bpf/die.cc
@@ -9,11 +9,12 @@
#include <string>
+#include "base/logging.h"
+#include "base/posix/eintr_wrapper.h"
#include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
#include "sandbox/linux/seccomp-bpf/syscall.h"
-
-namespace playground2 {
+namespace sandbox {
void Die::ExitGroup() {
// exit_group() should exit our program. After all, it is defined as a
@@ -29,8 +30,9 @@ void Die::ExitGroup() {
// succeeded in doing so. Nonetheless, triggering a fatal signal could help
// us terminate.
signal(SIGSEGV, SIG_DFL);
- SandboxSyscall(__NR_prctl, PR_SET_DUMPABLE, (void *)0, (void *)0, (void *)0);
- if (*(volatile char *)0) { }
+ SandboxSyscall(__NR_prctl, PR_SET_DUMPABLE, (void*)0, (void*)0, (void*)0);
+ if (*(volatile char*)0) {
+ }
// If there is no way for us to ask for the program to exit, the next
// best thing we can do is to loop indefinitely. Maybe, somebody will notice
@@ -42,37 +44,29 @@ void Die::ExitGroup() {
}
}
-void Die::SandboxDie(const char *msg, const char *file, int line) {
+void Die::SandboxDie(const char* msg, const char* file, int line) {
if (simple_exit_) {
LogToStderr(msg, file, line);
} else {
- #if defined(SECCOMP_BPF_STANDALONE)
- Die::LogToStderr(msg, file, line);
- #else
- logging::LogMessage(file, line, logging::LOG_FATAL).stream() << msg;
- #endif
+ logging::LogMessage(file, line, logging::LOG_FATAL).stream() << msg;
}
ExitGroup();
}
-void Die::RawSandboxDie(const char *msg) {
+void Die::RawSandboxDie(const char* msg) {
if (!msg)
msg = "";
RAW_LOG(FATAL, msg);
ExitGroup();
}
-void Die::SandboxInfo(const char *msg, const char *file, int line) {
+void Die::SandboxInfo(const char* msg, const char* file, int line) {
if (!suppress_info_) {
- #if defined(SECCOMP_BPF_STANDALONE)
- Die::LogToStderr(msg, file, line);
- #else
logging::LogMessage(file, line, logging::LOG_INFO).stream() << msg;
- #endif
}
}
-void Die::LogToStderr(const char *msg, const char *file, int line) {
+void Die::LogToStderr(const char* msg, const char* file, int line) {
if (msg) {
char buf[40];
snprintf(buf, sizeof(buf), "%d", line);
@@ -80,11 +74,12 @@ void Die::LogToStderr(const char *msg, const char *file, int line) {
// No need to loop. Short write()s are unlikely and if they happen we
// probably prefer them over a loop that blocks.
- if (HANDLE_EINTR(SandboxSyscall(__NR_write, 2, s.c_str(), s.length()))) { }
+ ignore_result(
+ HANDLE_EINTR(SandboxSyscall(__NR_write, 2, s.c_str(), s.length())));
}
}
-bool Die::simple_exit_ = false;
+bool Die::simple_exit_ = false;
bool Die::suppress_info_ = false;
-} // namespace
+} // namespace sandbox