Linux Sandbox: add RawSandboxDie()
Add an async signal safe version of SANDBOX_DIE(). BUG=277240 R=markus@chromium.org Review URL: https://codereview.chromium.org/23461032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221558 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -55,6 +55,13 @@ void Die::SandboxDie(const char *msg, const char *file, int line) {
|
||||
ExitGroup();
|
||||
}
|
||||
|
||||
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) {
|
||||
if (!suppress_info_) {
|
||||
#if defined(SECCOMP_BPF_STANDALONE)
|
||||
|
@ -13,9 +13,13 @@ namespace playground2 {
|
||||
class Die {
|
||||
public:
|
||||
// This is the main API for using this file. Prints a error message and
|
||||
// exits with a fatal error.
|
||||
// exits with a fatal error. This is not async-signal safe.
|
||||
#define SANDBOX_DIE(m) playground2::Die::SandboxDie(m, __FILE__, __LINE__)
|
||||
|
||||
// An async signal safe version of the same API. Won't print the filename
|
||||
// and line numbers.
|
||||
#define RAW_SANDBOX_DIE(m) playground2::Die::RawSandboxDie(m)
|
||||
|
||||
// Adds an informational message to the log file or stderr as appropriate.
|
||||
#define SANDBOX_INFO(m) playground2::Die::SandboxInfo(m, __FILE__, __LINE__)
|
||||
|
||||
@ -31,6 +35,8 @@ class Die {
|
||||
static void SandboxDie(const char *msg, const char *file, int line)
|
||||
__attribute__((noreturn));
|
||||
|
||||
static void RawSandboxDie(const char *msg) __attribute__((noreturn));
|
||||
|
||||
// This method gets called by SANDBOX_INFO(). There is normally no reason
|
||||
// to call it directly unless you are defining your own logging macro.
|
||||
static void SandboxInfo(const char *msg, const char *file, int line);
|
||||
|
@ -118,8 +118,8 @@ Trap *Trap::GetInstance() {
|
||||
|
||||
void Trap::SigSysAction(int nr, siginfo_t *info, void *void_context) {
|
||||
if (!global_trap_) {
|
||||
SANDBOX_DIE("This can't happen. Found no global singleton instance "
|
||||
"for Trap() handling.");
|
||||
RAW_SANDBOX_DIE("This can't happen. Found no global singleton instance "
|
||||
"for Trap() handling.");
|
||||
}
|
||||
global_trap_->SigSys(nr, info, void_context);
|
||||
}
|
||||
@ -162,14 +162,14 @@ void Trap::SigSys(int nr, siginfo_t *info, void *void_context) {
|
||||
// safe and can lead to bugs. We should eventually implement a different
|
||||
// logging and reporting mechanism that is safe to be called from
|
||||
// the sigSys() handler.
|
||||
SANDBOX_DIE("Sanity checks are failing after receiving SIGSYS.");
|
||||
RAW_SANDBOX_DIE("Sanity checks are failing after receiving SIGSYS.");
|
||||
}
|
||||
|
||||
intptr_t rc;
|
||||
if (has_unsafe_traps_ && GetIsInSigHandler(ctx)) {
|
||||
errno = old_errno;
|
||||
if (sigsys.nr == __NR_clone) {
|
||||
SANDBOX_DIE("Cannot call clone() from an UnsafeTrap() handler.");
|
||||
RAW_SANDBOX_DIE("Cannot call clone() from an UnsafeTrap() handler.");
|
||||
}
|
||||
rc = SandboxSyscall(sigsys.nr,
|
||||
SECCOMP_PARM1(ctx), SECCOMP_PARM2(ctx),
|
||||
|
@ -90,7 +90,10 @@ class Trap {
|
||||
static Trap *GetInstance();
|
||||
static void SigSysAction(int nr, siginfo_t *info, void *void_context);
|
||||
|
||||
void SigSys(int nr, siginfo_t *info, void *void_context);
|
||||
// Make sure that SigSys is not inlined in order to get slightly better crash
|
||||
// dumps.
|
||||
void SigSys(int nr, siginfo_t *info, void *void_context)
|
||||
__attribute__ ((noinline));
|
||||
ErrorCode MakeTrapImpl(TrapFnc fnc, const void *aux, bool safe);
|
||||
bool SandboxDebuggingAllowedByUser() const;
|
||||
|
||||
|
Reference in New Issue
Block a user