[PATCH] D46459: [asan] On RTEMS, checks for asan_inited before entering ASan run-time
Walter Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 4 13:48:44 PDT 2018
waltl created this revision.
waltl added reviewers: vitalybuka, eugenis, alekseyshl.
Herald added a subscriber: kubamracek.
On RTEMS, system and user code all live in a single binary and address
space. There is no clean separation, and instrumented code may
execute before the ASan run-time is initialized (or after it has been
destroyed). Add checks to entrypoints into the run-time to ensure
that the run-time is up beforing entering it.
Repository:
rL LLVM
https://reviews.llvm.org/D46459
Files:
compiler-rt/lib/asan/asan_poisoning.cc
compiler-rt/lib/asan/asan_rtl.cc
Index: compiler-rt/lib/asan/asan_rtl.cc
===================================================================
--- compiler-rt/lib/asan/asan_rtl.cc
+++ compiler-rt/lib/asan/asan_rtl.cc
@@ -95,16 +95,22 @@
#define ASAN_REPORT_ERROR(type, is_write, size) \
extern "C" NOINLINE INTERFACE_ATTRIBUTE \
void __asan_report_ ## type ## size(uptr addr) { \
+ if (SANITIZER_RTEMS && !asan_inited) \
+ return; \
GET_CALLER_PC_BP_SP; \
ReportGenericError(pc, bp, sp, addr, is_write, size, 0, true); \
} \
extern "C" NOINLINE INTERFACE_ATTRIBUTE \
void __asan_report_exp_ ## type ## size(uptr addr, u32 exp) { \
+ if (SANITIZER_RTEMS && !asan_inited) \
+ return; \
GET_CALLER_PC_BP_SP; \
ReportGenericError(pc, bp, sp, addr, is_write, size, exp, true); \
} \
extern "C" NOINLINE INTERFACE_ATTRIBUTE \
void __asan_report_ ## type ## size ## _noabort(uptr addr) { \
+ if (SANITIZER_RTEMS && !asan_inited) \
+ return; \
GET_CALLER_PC_BP_SP; \
ReportGenericError(pc, bp, sp, addr, is_write, size, 0, false); \
} \
@@ -123,24 +129,32 @@
#define ASAN_REPORT_ERROR_N(type, is_write) \
extern "C" NOINLINE INTERFACE_ATTRIBUTE \
void __asan_report_ ## type ## _n(uptr addr, uptr size) { \
+ if (SANITIZER_RTEMS && !asan_inited) \
+ return; \
GET_CALLER_PC_BP_SP; \
ReportGenericError(pc, bp, sp, addr, is_write, size, 0, true); \
} \
extern "C" NOINLINE INTERFACE_ATTRIBUTE \
void __asan_report_exp_ ## type ## _n(uptr addr, uptr size, u32 exp) { \
+ if (SANITIZER_RTEMS && !asan_inited) \
+ return; \
GET_CALLER_PC_BP_SP; \
ReportGenericError(pc, bp, sp, addr, is_write, size, exp, true); \
} \
extern "C" NOINLINE INTERFACE_ATTRIBUTE \
void __asan_report_ ## type ## _n_noabort(uptr addr, uptr size) { \
+ if (SANITIZER_RTEMS && !asan_inited) \
+ return; \
GET_CALLER_PC_BP_SP; \
ReportGenericError(pc, bp, sp, addr, is_write, size, 0, false); \
} \
ASAN_REPORT_ERROR_N(load, false)
ASAN_REPORT_ERROR_N(store, true)
#define ASAN_MEMORY_ACCESS_CALLBACK_BODY(type, is_write, size, exp_arg, fatal) \
+ if (SANITIZER_RTEMS && !asan_inited) \
+ return; \
if (SANITIZER_RTEMS && !AddrIsInMem(addr) && !AddrIsInShadow(addr)) \
return; \
uptr sp = MEM_TO_SHADOW(addr); \
@@ -524,6 +538,9 @@
using namespace __asan; // NOLINT
void NOINLINE __asan_handle_no_return() {
+ if (SANITIZER_RTEMS && !asan_inited)
+ return;
+
if (asan_init_is_running)
return;
Index: compiler-rt/lib/asan/asan_poisoning.cc
===================================================================
--- compiler-rt/lib/asan/asan_poisoning.cc
+++ compiler-rt/lib/asan/asan_poisoning.cc
@@ -181,6 +181,8 @@
uptr __asan_region_is_poisoned(uptr beg, uptr size) {
if (!size) return 0;
+ if (SANITIZER_RTEMS && !asan_inited)
+ return 0;
uptr end = beg + size;
if (SANITIZER_MYRIAD2) {
// On Myriad, address not in DRAM range need to be treated as
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46459.145276.patch
Type: text/x-patch
Size: 4765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180504/c0c2f093/attachment.bin>
More information about the llvm-commits
mailing list