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:
Justine Tunney 2024-06-22 05:45:49 -07:00
parent 6ffed14b9c
commit d1d4388201
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
198 changed files with 130 additions and 2954 deletions

View file

@ -1897,7 +1897,7 @@ _Py_NewReference(PyObject *op)
_Py_INC_TPALLOCS(op);
}
dontasan void
void
_Py_ForgetReference(PyObject *op)
{
#ifdef SLOW_UNREF_CHECK

View file

@ -7,7 +7,6 @@
#include "libc/assert.h"
#include "libc/calls/calls.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/sysv/consts/map.h"
@ -1876,13 +1875,13 @@ bumpserialno(void)
#define SST SIZEOF_SIZE_T
static inline optimizespeed dontasan size_t
static inline optimizespeed size_t
read_size_t(const void *p)
{
return READ64BE(p);
}
static inline optimizespeed dontasan void
static inline optimizespeed void
write_size_t(void *p, size_t n)
{
WRITE64BE((char *)p, n);
@ -1950,11 +1949,6 @@ _PyMem_DebugRawAlloc(int use_calloc, void *ctx, size_t nbytes)
write_size_t(tail + SST, serialno);
_PyMem_DebugCheckAddress(api->api_id, p+2*SST);
if (IsAsan()) {
__asan_poison((p + SST + 1), SST-1, kAsanHeapUnderrun);
__asan_poison(tail, SST, kAsanHeapOverrun);
}
return p + 2*SST;
}
@ -2007,15 +2001,12 @@ _PyMem_DebugRawFree(void *ctx, void *p)
nbytes = read_size_t(q);
nbytes += 4*SST;
if (nbytes > 0) {
if (IsAsan()) {
__asan_unpoison(q, nbytes);
}
memset(q, DEADBYTE, nbytes);
}
api->alloc.free(api->alloc.ctx, q);
}
static dontasan void *
static void *
_PyMem_DebugRawRealloc(void *ctx, void *p, size_t nbytes)
{
_Static_assert(sizeof(size_t) == 8, "");
@ -2047,14 +2038,9 @@ _PyMem_DebugRawRealloc(void *ctx, void *p, size_t nbytes)
tail = q + nbytes;
w = 0x0101010101010101ull * FORBIDDENBYTE;
WRITE64LE(tail, w);
if (IsAsan()) __asan_poison(tail, SST, kAsanHeapOverrun);
write_size_t(tail + SST, serialno);
if (nbytes > original_nbytes) {
/* growing: mark new extra memory clean */
if (IsAsan()) {
__asan_unpoison((q + original_nbytes),
nbytes - original_nbytes);
}
memset(q + original_nbytes, CLEANBYTE,
nbytes - original_nbytes);
}
@ -2104,7 +2090,7 @@ _PyMem_DebugRealloc(void *ctx, void *ptr, size_t nbytes)
* and call Py_FatalError to kill the program.
* The API id, is also checked.
*/
static dontasan void
static void
_PyMem_DebugCheckAddress(char api, const void *p)
{
const uint8_t *q = (const uint8_t *)p;
@ -2157,7 +2143,7 @@ error:
}
/* Display info to stderr about the memory block at p. */
static dontasan void
static void
_PyObject_DebugDumpAddress(const void *p)
{
const uint8_t *q = (const uint8_t *)p;