Bug 1081242 - Make ASAN's error reporting work while sandboxed on Linux. r=kang

This commit is contained in:
Jed Davis 2014-10-21 11:18:00 +02:00
parent e3277f83ab
commit 5ec3c350dd
2 changed files with 36 additions and 0 deletions

View File

@ -37,6 +37,26 @@
// See definition of SandboxDie, below.
#include "sandbox/linux/seccomp-bpf/die.h"
#ifdef MOZ_ASAN
// Copy libsanitizer declarations to avoid depending on ASAN headers.
// See also bug 1081242 comment #4.
extern "C" {
namespace __sanitizer {
// Win64 uses long long, but this is Linux.
typedef signed long sptr;
} // namespace __sanitizer
typedef struct {
int coverage_sandboxed;
__sanitizer::sptr coverage_fd;
unsigned int coverage_max_block_size;
} __sanitizer_sandbox_arguments;
MOZ_IMPORT_API void
__sanitizer_sandbox_on_notify(__sanitizer_sandbox_arguments *args);
} // extern "C"
#endif // MOZ_ASAN
namespace mozilla {
SandboxCrashFunc gSandboxCrashFunc;
@ -415,6 +435,14 @@ SetCurrentProcessSandbox(SandboxType aType)
SANDBOX_LOG_ERROR("install_syscall_reporter() failed\n");
}
#ifdef MOZ_ASAN
__sanitizer_sandbox_arguments asanArgs;
asanArgs.coverage_sandboxed = 1;
asanArgs.coverage_fd = -1;
asanArgs.coverage_max_block_size = 0;
__sanitizer_sandbox_on_notify(&asanArgs);
#endif
BroadcastSetThreadSandbox(aType);
}

View File

@ -396,6 +396,14 @@ void SandboxFilterImplGMP::Build() {
#ifdef MOZ_ASAN
Allow(SYSCALL(sigaltstack));
// ASAN's error reporter wants to know if stderr is a tty.
Deny(ENOTTY, SYSCALL_WITH_ARG(ioctl, 0, STDERR_FILENO));
// ...and before compiler-rt r209773, it will call readlink and use
// the cached value only if that fails:
Deny(ENOENT, SYSCALL(readlink));
// ...and if it found an external symbolizer, it will try to run it:
// (See also bug 1081242 comment #7.)
Deny(ENOENT, SYSCALL_LARGEFILE(stat, stat64));
#endif
Allow(SYSCALL(mprotect));