Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Side by Side Diff: sandbox/linux/seccomp-bpf/die.cc

Issue 23461032: Linux Sandbox: add RawSandboxDie() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: __attribute__ ((noinline)) for SigSys Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sandbox/linux/seccomp-bpf/die.h ('k') | sandbox/linux/seccomp-bpf/trap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <linux/unistd.h> 6 #include <linux/unistd.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <sys/prctl.h> 8 #include <sys/prctl.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } else { 48 } else {
49 #if defined(SECCOMP_BPF_STANDALONE) 49 #if defined(SECCOMP_BPF_STANDALONE)
50 Die::LogToStderr(msg, file, line); 50 Die::LogToStderr(msg, file, line);
51 #else 51 #else
52 logging::LogMessage(file, line, logging::LOG_FATAL).stream() << msg; 52 logging::LogMessage(file, line, logging::LOG_FATAL).stream() << msg;
53 #endif 53 #endif
54 } 54 }
55 ExitGroup(); 55 ExitGroup();
56 } 56 }
57 57
58 void Die::RawSandboxDie(const char *msg) {
59 if (!msg)
60 msg = "";
61 RAW_LOG(FATAL, msg);
62 ExitGroup();
63 }
64
58 void Die::SandboxInfo(const char *msg, const char *file, int line) { 65 void Die::SandboxInfo(const char *msg, const char *file, int line) {
59 if (!suppress_info_) { 66 if (!suppress_info_) {
60 #if defined(SECCOMP_BPF_STANDALONE) 67 #if defined(SECCOMP_BPF_STANDALONE)
61 Die::LogToStderr(msg, file, line); 68 Die::LogToStderr(msg, file, line);
62 #else 69 #else
63 logging::LogMessage(file, line, logging::LOG_INFO).stream() << msg; 70 logging::LogMessage(file, line, logging::LOG_INFO).stream() << msg;
64 #endif 71 #endif
65 } 72 }
66 } 73 }
67 74
68 void Die::LogToStderr(const char *msg, const char *file, int line) { 75 void Die::LogToStderr(const char *msg, const char *file, int line) {
69 if (msg) { 76 if (msg) {
70 char buf[40]; 77 char buf[40];
71 snprintf(buf, sizeof(buf), "%d", line); 78 snprintf(buf, sizeof(buf), "%d", line);
72 std::string s = std::string(file) + ":" + buf + ":" + msg + "\n"; 79 std::string s = std::string(file) + ":" + buf + ":" + msg + "\n";
73 80
74 // No need to loop. Short write()s are unlikely and if they happen we 81 // No need to loop. Short write()s are unlikely and if they happen we
75 // probably prefer them over a loop that blocks. 82 // probably prefer them over a loop that blocks.
76 if (HANDLE_EINTR(SandboxSyscall(__NR_write, 2, s.c_str(), s.length()))) { } 83 if (HANDLE_EINTR(SandboxSyscall(__NR_write, 2, s.c_str(), s.length()))) { }
77 } 84 }
78 } 85 }
79 86
80 bool Die::simple_exit_ = false; 87 bool Die::simple_exit_ = false;
81 bool Die::suppress_info_ = false; 88 bool Die::suppress_info_ = false;
82 89
83 } // namespace 90 } // namespace
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/die.h ('k') | sandbox/linux/seccomp-bpf/trap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698