mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-22 18:40:29 +00:00
Delete ASAN
It hasn't been helpful enough to be justify the maintenance burden. What actually does help is mprotect(), kprintf(), --ftrace and --strace which can always be counted upon to work correctly. We aren't losing much with this change. Support for ASAN on AARCH64 was never implemented. Applying ASAN to the core libc runtimes was disabled many months ago. If there is some way to have an ASAN runtime for user programs that is less invasive we can potentially consider reintroducing support. But now is premature.
This commit is contained in:
parent
6ffed14b9c
commit
d1d4388201
198 changed files with 130 additions and 2954 deletions
|
@ -62,12 +62,6 @@ o/$(MODE)/libc/intrin/kprintf.o: private \
|
|||
-Wframe-larger-than=128 \
|
||||
-Walloca-larger-than=128
|
||||
|
||||
o/$(MODE)/libc/intrin/asan.o: private \
|
||||
CFLAGS += \
|
||||
-O2 \
|
||||
-finline \
|
||||
-finline-functions
|
||||
|
||||
o//libc/intrin/memmove.o: private \
|
||||
CFLAGS += \
|
||||
-fno-toplevel-reorder
|
||||
|
|
1126
libc/intrin/asan.c
1126
libc/intrin/asan.c
File diff suppressed because it is too large
Load diff
|
@ -1,71 +0,0 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_INTRIN_ASAN_H_
|
||||
#define COSMOPOLITAN_LIBC_INTRIN_ASAN_H_
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/intrin/asancodes.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/stackframe.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#ifdef MODE_DBG
|
||||
// MODE=dbg
|
||||
// O(32mb) of morgue memory
|
||||
// Θ(64) bytes of malloc overhead
|
||||
#define ASAN_MORGUE_ITEMS 512
|
||||
#define ASAN_MORGUE_THRESHOLD 65536
|
||||
#define ASAN_TRACE_ITEMS 16
|
||||
#else
|
||||
// MODE=asan
|
||||
// O(32mb) of morgue memory
|
||||
// Θ(32) bytes of malloc overhead
|
||||
#define ASAN_MORGUE_ITEMS 512
|
||||
#define ASAN_MORGUE_THRESHOLD 65536
|
||||
#define ASAN_TRACE_ITEMS 4
|
||||
#endif
|
||||
|
||||
#define SHADOW(x) ((signed char *)(((intptr_t)(x) >> kAsanScale) + kAsanMagic))
|
||||
#define UNSHADOW(x) ((void *)(MAX(0, (intptr_t)(x) - kAsanMagic) << kAsanScale))
|
||||
|
||||
#define __asan_unreachable() \
|
||||
do { \
|
||||
kprintf("%s:%d: __asan_unreachable()\n", __FILE__, __LINE__); \
|
||||
__builtin_trap(); \
|
||||
} while (0)
|
||||
|
||||
typedef void __asan_die_f(void);
|
||||
|
||||
struct AsanFault {
|
||||
signed char kind;
|
||||
const signed char *shadow;
|
||||
};
|
||||
|
||||
struct AsanTrace {
|
||||
uint32_t p[ASAN_TRACE_ITEMS]; // assumes linkage into 32-bit space
|
||||
};
|
||||
|
||||
void __asan_unpoison(void *, long);
|
||||
void __asan_poison(void *, long, signed char);
|
||||
void __asan_verify(const void *, size_t);
|
||||
void __asan_verify_str(const char *);
|
||||
void __asan_shadow(void *, size_t);
|
||||
void __asan_unshadow(void *, size_t);
|
||||
bool __asan_is_valid(const void *, long) nosideeffect;
|
||||
bool __asan_is_valid_str(const char *) nosideeffect;
|
||||
bool __asan_is_valid_strlist(char *const *) nosideeffect;
|
||||
bool __asan_is_valid_iov(const struct iovec *, int) nosideeffect;
|
||||
struct AsanFault __asan_check(const void *, long) nosideeffect;
|
||||
struct AsanFault __asan_check_str(const char *) nosideeffect;
|
||||
|
||||
int __asan_is_leaky(void *);
|
||||
int __asan_print_trace(void *);
|
||||
bool __asan_is_mapped(const void *);
|
||||
__asan_die_f *__asan_die(void) __wur;
|
||||
void __asan_memset(void *, char, size_t);
|
||||
size_t __asan_get_heap_size(const void *);
|
||||
void *__asan_memcpy(void *, const void *, size_t);
|
||||
void __asan_rawtrace(struct AsanTrace *, const struct StackFrame *);
|
||||
void __asan_report_memory_origin(const unsigned char *, int, signed char);
|
||||
void __asan_report_memory_origin_image(intptr_t, int);
|
||||
void __asan_report_memory_origin_heap(const unsigned char *, int);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_ASAN_H_ */
|
|
@ -1,29 +0,0 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_INTRIN_ASANCODES_H_
|
||||
#define COSMOPOLITAN_LIBC_INTRIN_ASANCODES_H_
|
||||
|
||||
#define kAsanScale 3
|
||||
#define kAsanMagic 0x7fff8000
|
||||
#define kAsanNullPage -1 /* ∅ 0xff */
|
||||
#define kAsanProtected -2 /* P 0xfe */
|
||||
#define kAsanHeapFree -3 /* F 0xfd */
|
||||
#define kAsanHeapRelocated -4 /* R 0xfc */
|
||||
#define kAsanAllocaOverrun -5 /* 𝑂 0xfb */
|
||||
#define kAsanHeapUnderrun -6 /* U 0xfa */
|
||||
#define kAsanHeapOverrun -7 /* O 0xf9 */
|
||||
#define kAsanStackUnscoped -8 /* s 0xf8 */
|
||||
#define kAsanStackOverflow -9 /* ! 0xf7 */
|
||||
#define kAsanGlobalOrder -10 /* I 0xf6 */
|
||||
#define kAsanStackFree -11 /* r 0xf5 */
|
||||
#define kAsanStackPartial -12 /* p 0xf4 */
|
||||
#define kAsanStackOverrun -13 /* o 0xf3 */
|
||||
#define kAsanStackMiddle -14 /* m 0xf2 */
|
||||
#define kAsanStackUnderrun -15 /* u 0xf1 */
|
||||
#define kAsanAllocaUnderrun -16 /* 𝑈 0xf0 */
|
||||
#define kAsanUnmapped -17 /* M 0xef */
|
||||
#define kAsanGlobalRedzone -18 /* G 0xee */
|
||||
#define kAsanGlobalGone -19 /* 𝐺 0xed */
|
||||
#define kAsanGlobalUnderrun -20 /* μ 0xec */
|
||||
#define kAsanGlobalOverrun -21 /* Ω 0xeb */
|
||||
#define kAsanMmapSizeOverrun -22 /* Z 0xea */
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_ASANCODES_H_ */
|
|
@ -1,31 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│ vi: set noet ft=asm ts=8 sw=8 fenc=utf-8 :vi │
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
.init.start 303,_init_asan
|
||||
#ifdef __x86_64__
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
push %rdi
|
||||
push %rsi
|
||||
call __asan_init
|
||||
pop %rsi
|
||||
pop %rdi
|
||||
#endif /* __SANITIZE_ADDRESS__ */
|
||||
#endif /* __x86_64__ */
|
||||
.init.end 303,_init_asan
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/sock/select.h"
|
||||
|
@ -32,8 +31,7 @@ const char *(DescribeFdSet)(char buf[N], ssize_t rc, int nfds, fd_set *fds) {
|
|||
|
||||
if (!fds)
|
||||
return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(fds)) ||
|
||||
(IsAsan() && !__asan_is_valid(fds, sizeof(*fds) * nfds))) {
|
||||
if (kisdangerous(fds)) {
|
||||
ksnprintf(buf, N, "%p", fds);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "libc/calls/struct/flock.h"
|
||||
#include "libc/calls/struct/flock.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
|
@ -33,8 +32,7 @@ const char *(DescribeFlock)(char buf[N], int cmd, const struct flock *l) {
|
|||
|
||||
if (!l)
|
||||
return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(l)) ||
|
||||
(IsAsan() && !__asan_is_valid(l, sizeof(*l)))) {
|
||||
if (kisdangerous(l)) {
|
||||
ksnprintf(buf, N, "%p", l);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/groups.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/popcnt.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
@ -34,8 +33,7 @@ const char *(DescribeGidList)(char buf[N], int rc, int size,
|
|||
return "{}";
|
||||
if (!list)
|
||||
return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(list)) ||
|
||||
(IsAsan() && !__asan_is_valid(list, size * sizeof(list[0])))) {
|
||||
if (kisdangerous(list)) {
|
||||
ksnprintf(buf, N, "%p", list);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/calls/struct/iovec.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
@ -39,8 +38,7 @@ const char *(DescribeIovec)(char buf[N], ssize_t rc, const struct iovec *iov,
|
|||
return "n/a";
|
||||
if (rc == -2)
|
||||
rc = SSIZE_MAX;
|
||||
if ((!IsAsan() && kisdangerous(iov)) ||
|
||||
(IsAsan() && !__asan_is_valid(iov, sizeof(*iov) * iovlen))) {
|
||||
if (kisdangerous(iov)) {
|
||||
ksnprintf(buf, N, "%p", iov);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
@ -25,8 +24,7 @@
|
|||
|
||||
void DescribeIovNt(const struct NtIovec *iov, uint32_t iovlen, ssize_t rem) {
|
||||
int i;
|
||||
if ((!IsAsan() && kisdangerous(iov)) ||
|
||||
(IsAsan() && !__asan_is_valid(iov, iovlen * sizeof(struct NtIovec)))) {
|
||||
if (kisdangerous(iov)) {
|
||||
kprintf("%p", iov);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/calls/struct/timeval.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
|
||||
|
@ -32,8 +31,7 @@ const char *(DescribeItimerval)(char buf[N], int rc,
|
|||
return "NULL";
|
||||
if (rc == -1)
|
||||
return "n/a";
|
||||
if ((!IsAsan() && kisdangerous(it)) ||
|
||||
(IsAsan() && !__asan_is_valid(it, sizeof(*it)))) {
|
||||
if (kisdangerous(it)) {
|
||||
ksnprintf(buf, N, "%p", it);
|
||||
} else {
|
||||
ksnprintf(buf, N, "{%s, %s}", DescribeTimeval(0, &it->it_interval),
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/limits.h"
|
||||
|
@ -36,8 +35,7 @@ const char *(DescribePollFds)(char buf[N], ssize_t rc, struct pollfd *fds,
|
|||
|
||||
if (!fds)
|
||||
return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(fds)) ||
|
||||
(IsAsan() && !__asan_is_valid(fds, sizeof(*fds) * nfds))) {
|
||||
if (kisdangerous(fds)) {
|
||||
ksnprintf(buf, N, "%p", fds);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/rlimit.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
|
||||
|
@ -27,8 +26,7 @@ const char *DescribeRlimit(char buf[64], int rc, const struct rlimit *rlim) {
|
|||
return "n/a";
|
||||
if (!rlim)
|
||||
return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(rlim)) ||
|
||||
(IsAsan() && !__asan_is_valid(rlim, sizeof(*rlim)))) {
|
||||
if (kisdangerous(rlim)) {
|
||||
ksnprintf(buf, 64, "%p", rlim);
|
||||
} else {
|
||||
ksnprintf(buf, 64, "{%'ld, %'ld}", rlim->rlim_cur, rlim->rlim_max);
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/calls/struct/sigset.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/alloca.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
|
||||
|
@ -67,8 +67,7 @@ const char *(DescribeSigaction)(char buf[N], int rc,
|
|||
return "n/a";
|
||||
if (!sa)
|
||||
return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(sa)) ||
|
||||
(IsAsan() && !__asan_is_valid(sa, sizeof(*sa)))) {
|
||||
if (kisdangerous(sa)) {
|
||||
ksnprintf(buf, N, "%p", sa);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/sigaltstack.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
|
||||
|
@ -28,8 +27,7 @@ const char *(DescribeSigaltstk)(char buf[128], int rc,
|
|||
return "n/a";
|
||||
if (!ss)
|
||||
return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(ss)) ||
|
||||
(IsAsan() && !__asan_is_valid(ss, sizeof(*ss)))) {
|
||||
if (kisdangerous(ss)) {
|
||||
ksnprintf(buf, 128, "%p", ss);
|
||||
} else {
|
||||
ksnprintf(buf, 128, "{.ss_sp=%p, .ss_flags=%#lx, .ss_size=%'zu}", ss->ss_sp,
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "libc/calls/struct/siginfo.h"
|
||||
#include "libc/calls/struct/siginfo.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
|
@ -37,8 +36,7 @@ const char *(DescribeSiginfo)(char buf[N], int rc, const siginfo_t *si) {
|
|||
return "n/a";
|
||||
if (!si)
|
||||
return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(si)) ||
|
||||
(IsAsan() && !__asan_is_valid(si, sizeof(*si)))) {
|
||||
if (kisdangerous(si)) {
|
||||
ksnprintf(buf, N, "%p", si);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "libc/calls/struct/sigset.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/popcnt.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -43,8 +42,7 @@ const char *(DescribeSigset)(char buf[N], int rc, const sigset_t *ss) {
|
|||
return "n/a";
|
||||
if (!ss)
|
||||
return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(ss)) ||
|
||||
(IsAsan() && !__asan_is_valid(ss, sizeof(*ss)))) {
|
||||
if (kisdangerous(ss)) {
|
||||
ksnprintf(buf, N, "%p", ss);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/struct/stat.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
|
||||
#define N 300
|
||||
|
@ -33,8 +32,7 @@ const char *(DescribeStat)(char buf[N], int rc, const struct stat *st) {
|
|||
return "n/a";
|
||||
if (!st)
|
||||
return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(st)) ||
|
||||
(IsAsan() && !__asan_is_valid(st, sizeof(*st)))) {
|
||||
if (kisdangerous(st)) {
|
||||
ksnprintf(buf, N, "%p", st);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "libc/calls/struct/statfs.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/sysv/consts/st.h"
|
||||
|
||||
|
@ -37,8 +36,7 @@ const char *(DescribeStatfs)(char buf[N], int rc, const struct statfs *f) {
|
|||
return "n/a";
|
||||
if (!f)
|
||||
return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(f)) ||
|
||||
(IsAsan() && !__asan_is_valid(f, sizeof(*f)))) {
|
||||
if (kisdangerous(f)) {
|
||||
ksnprintf(buf, N, "%p", f);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
|
||||
|
@ -30,10 +29,6 @@ const char *(DescribeStringList)(char buf[N], char *const list[]) {
|
|||
|
||||
if (!list)
|
||||
return "NULL";
|
||||
if (IsAsan() && !__asan_is_valid_strlist(list)) {
|
||||
ksnprintf(buf, N, "%p", list);
|
||||
return buf;
|
||||
}
|
||||
|
||||
append("{");
|
||||
i = 0;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "libc/calls/struct/termios.internal.h"
|
||||
#include "libc/calls/ttydefaults.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
@ -37,8 +36,7 @@ const char *(DescribeTermios)(char buf[N], ssize_t rc,
|
|||
|
||||
if (!tio)
|
||||
return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(tio)) ||
|
||||
(IsAsan() && !__asan_is_valid(tio, sizeof(*tio)))) {
|
||||
if (kisdangerous(tio)) {
|
||||
ksnprintf(buf, N, "%p", tio);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -29,8 +28,7 @@ const char *(DescribeTimespec)(char buf[45], int rc,
|
|||
return "n/a";
|
||||
if (!ts)
|
||||
return "NULL";
|
||||
if ((!IsAsan() && kisdangerous(ts)) ||
|
||||
(IsAsan() && !__asan_is_valid(ts, sizeof(*ts)))) {
|
||||
if (kisdangerous(ts)) {
|
||||
ksnprintf(buf, 45, "%p", ts);
|
||||
} else {
|
||||
if (!memcmp(ts, ×pec_max, sizeof(*ts))) {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
|
||||
|
@ -27,8 +26,7 @@ const char *(DescribeTimeval)(char buf[45], int rc, const struct timeval *tv) {
|
|||
return "NULL";
|
||||
if (rc == -1)
|
||||
return "n/a";
|
||||
if ((!IsAsan() && kisdangerous(tv)) ||
|
||||
(IsAsan() && !__asan_is_valid(tv, sizeof(*tv)))) {
|
||||
if (kisdangerous(tv)) {
|
||||
ksnprintf(buf, 45, "%p", tv);
|
||||
} else {
|
||||
ksnprintf(buf, 45, "{%ld, %ld}", tv->tv_sec, tv->tv_usec);
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "libc/calls/struct/winsize.h"
|
||||
#include "libc/calls/struct/winsize.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/limits.h"
|
||||
|
@ -35,8 +34,7 @@ const char *(DescribeWinsize)(char buf[N], int rc, const struct winsize *ws) {
|
|||
return "NULL";
|
||||
if (rc == -1)
|
||||
return "n/a";
|
||||
if ((!IsAsan() && kisdangerous(ws)) ||
|
||||
(IsAsan() && !__asan_is_valid(ws, sizeof(*ws)))) {
|
||||
if (kisdangerous(ws)) {
|
||||
ksnprintf(buf, N, "%p", ws);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
@ -47,14 +46,6 @@
|
|||
*/
|
||||
void *_extend(void *p, size_t n, void *e, int f, intptr_t h) {
|
||||
char *q;
|
||||
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
if ((uintptr_t)SHADOW(p) & (G - 1))
|
||||
__builtin_trap();
|
||||
if ((uintptr_t)p + (G << kAsanScale) > h)
|
||||
__builtin_trap();
|
||||
#endif
|
||||
|
||||
for (q = e; q < ((char *)p + n); q += 8) {
|
||||
if (!((uintptr_t)q & (G - 1))) {
|
||||
if (q + G > (char *)h)
|
||||
|
@ -64,6 +55,5 @@ void *_extend(void *p, size_t n, void *e, int f, intptr_t h) {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return q;
|
||||
}
|
||||
|
|
|
@ -3,14 +3,7 @@
|
|||
#include "libc/dce.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#if IsAsan()
|
||||
#define IGNORE_LEAKS(FUNC) \
|
||||
__static_yoink("_leaky_start"); \
|
||||
void *_leaky_##FUNC[] _Section(".piro.relo.sort.leaky.2." #FUNC \
|
||||
",\"aw\",@init_array #") = {FUNC};
|
||||
#else
|
||||
#define IGNORE_LEAKS(FUNC)
|
||||
#endif
|
||||
|
||||
extern intptr_t _leaky_end[] __attribute__((__weak__));
|
||||
extern intptr_t _leaky_start[] __attribute__((__weak__));
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/str/str.h"
|
||||
#ifndef __aarch64__
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/nexgen32e/nexgen32e.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -159,7 +158,7 @@ static __vex void *__memmove(void *dst, const void *src, size_t n) {
|
|||
#if defined(__x86_64__) && !defined(__chibicc__)
|
||||
if (n < kHalfCache3 || !kHalfCache3) {
|
||||
if (d > s) {
|
||||
if (IsAsan() || n < 900 || !X86_HAVE(ERMS)) {
|
||||
if (n < 900 || !X86_HAVE(ERMS)) {
|
||||
do {
|
||||
n -= 32;
|
||||
v = *(const xmm_t *)(s + n);
|
||||
|
@ -176,7 +175,7 @@ static __vex void *__memmove(void *dst, const void *src, size_t n) {
|
|||
return dst;
|
||||
}
|
||||
} else {
|
||||
if (IsAsan() || n < 900 || !X86_HAVE(ERMS)) {
|
||||
if (n < 900 || !X86_HAVE(ERMS)) {
|
||||
i = 0;
|
||||
do {
|
||||
v = *(const xmm_t *)(s + i);
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/directmap.internal.h"
|
||||
|
@ -114,10 +113,7 @@ static bool __overlaps_existing_map(const char *addr, size_t size) {
|
|||
}
|
||||
|
||||
static int __munmap_chunk(void *addr, size_t size) {
|
||||
int rc = sys_munmap(addr, size);
|
||||
if (IsAsan() && !rc)
|
||||
__asan_unshadow(addr, size);
|
||||
return rc;
|
||||
return sys_munmap(addr, size);
|
||||
}
|
||||
|
||||
static int __munmap(char *addr, size_t size, bool untrack_only) {
|
||||
|
@ -410,12 +406,6 @@ void *__mmap(char *addr, size_t size, int prot, int flags, int fd,
|
|||
void *mmap(void *addr, size_t size, int prot, int flags, int fd, int64_t off) {
|
||||
void *res;
|
||||
res = __mmap(addr, size, prot, flags, fd, off);
|
||||
if (IsAsan() && res != MAP_FAILED) {
|
||||
__asan_shadow(res, size);
|
||||
int granularity = __granularity();
|
||||
if (size != PGUP(size))
|
||||
__asan_poison(res + size, PGUP(size) - size, kAsanMmapSizeOverrun);
|
||||
}
|
||||
STRACE("mmap(%p, %'zu, %s, %s, %d, %'ld) → %p% m", addr, size,
|
||||
DescribeProtFlags(prot), DescribeMapFlags(flags), fd, off, res);
|
||||
return res;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "libc/calls/struct/sigset.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -51,12 +50,7 @@
|
|||
int sigprocmask(int how, const sigset_t *opt_set, sigset_t *opt_out_oldset) {
|
||||
int rc;
|
||||
sigset_t old = {0};
|
||||
if (IsAsan() &&
|
||||
((opt_set && !__asan_is_valid(opt_set, sizeof(*opt_set))) ||
|
||||
(opt_out_oldset &&
|
||||
!__asan_is_valid(opt_out_oldset, sizeof(*opt_out_oldset))))) {
|
||||
rc = efault();
|
||||
} else if (IsMetal() || IsWindows()) {
|
||||
if (IsMetal() || IsWindows()) {
|
||||
rc = __sig_mask(how, opt_set, &old);
|
||||
} else {
|
||||
rc = sys_sigprocmask(how, opt_set, opt_out_oldset ? &old : 0);
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#ifndef __aarch64__
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue