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

@ -17,7 +17,6 @@
// parser.
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/log/libfatal.internal.h"
#include "libc/log/log.h"
#include "libc/mem/mem.h"

View file

@ -46,8 +46,7 @@ $(THIRD_PARTY_COMPILER_RT_A).pkg: \
$(THIRD_PARTY_COMPILER_RT_A_OBJS): private \
DEFAULT_CFLAGS += \
$(OLD_CODE) \
-DCRT_HAS_128BIT \
-fno-sanitize=address
-DCRT_HAS_128BIT
# these assembly files are safe to build on aarch64
o/$(MODE)/third_party/compiler_rt/comprt.o: third_party/compiler_rt/comprt.S

View file

@ -55,7 +55,6 @@ $(THIRD_PARTY_DLMALLOC_A_OBJS): private \
-ffreestanding \
-fdata-sections \
-ffunction-sections \
-fno-sanitize=address \
-Wframe-larger-than=4096 \
-Walloca-larger-than=4096

View file

@ -17,8 +17,6 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/asancodes.h"
#include "libc/runtime/runtime.h"
#include "third_party/dlmalloc/vespene.internal.h"
@ -27,9 +25,5 @@
* @return memory map address on success, or null w/ errno
*/
void *dlmalloc_requires_more_vespene_gas(size_t size) {
char *p;
if ((p = _mapanon(size)))
if (IsAsan())
__asan_poison(p, size, kAsanHeapFree);
return p;
return _mapanon(size);
}

View file

@ -34,8 +34,6 @@ $(THIRD_PARTY_GETOPT_A).pkg: \
$(THIRD_PARTY_GETOPT_A_OBJS) \
$(foreach x,$(THIRD_PARTY_GETOPT_A_DIRECTDEPS),$($(x)_A).pkg)
$(THIRD_PARTY_GETOPT_A_OBJS): private COPTS += -fno-sanitize=address
THIRD_PARTY_GETOPT_LIBS = $(foreach x,$(THIRD_PARTY_GETOPT_ARTIFACTS),$($(x)))
THIRD_PARTY_GETOPT_SRCS = $(foreach x,$(THIRD_PARTY_GETOPT_ARTIFACTS),$($(x)_SRCS))
THIRD_PARTY_GETOPT_HDRS = $(foreach x,$(THIRD_PARTY_GETOPT_ARTIFACTS),$($(x)_HDRS))

View file

@ -138,7 +138,6 @@
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/intrin/asan.internal.h"
#include "libc/serialize.h"
#include "libc/intrin/bsr.h"
#include "libc/intrin/nomultics.internal.h"

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/asan.internal.h"
#include "libc/nexgen32e/x86feature.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
@ -411,8 +410,6 @@ int mbedtls_p384_double_jac( const mbedtls_ecp_group *G,
{
int ret;
uint64_t T[4][12];
if( IsAsan() ) __asan_verify( P, sizeof( *P ) );
if( IsAsan() ) __asan_verify( R, sizeof( *R ) );
if( ( ret = mbedtls_p384_dim( R ) ) ) return( ret );
if( ( ret = mbedtls_p384_dim( (void *)P ) ) ) return( ret );
mbedtls_platform_zeroize( T, sizeof( T ) );
@ -453,10 +450,6 @@ int mbedtls_p384_add_mixed( const mbedtls_ecp_group *G,
uint64_t T1[12], T2[12], T3[12], T4[12];
size_t Xn, Yn, Zn, QXn, QYn;
} s;
if( IsAsan() ) __asan_verify( G, sizeof( *G ) );
if( IsAsan() ) __asan_verify( P, sizeof( *P ) );
if( IsAsan() ) __asan_verify( Q, sizeof( *Q ) );
if( IsAsan() ) __asan_verify( R, sizeof( *R ) );
if( ( ret = mbedtls_p384_dim( R ) ) ) return( ret );
mbedtls_platform_zeroize( &s, sizeof( s ) );
s.Xn = mbedtls_mpi_limbs( &P->X );

View file

@ -16,7 +16,6 @@
limitations under the License.
*/
#include "third_party/mbedtls/sha1.h"
#include "libc/intrin/asan.internal.h"
#include "libc/serialize.h"
#include "libc/macros.internal.h"
#include "libc/nexgen32e/sha.h"
@ -111,11 +110,6 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
if( X86_HAVE( SHA ) )
{
if( IsAsan() )
{
__asan_verify( data, 64 );
__asan_verify( ctx, sizeof(*ctx) );
}
sha1_transform_ni( ctx->state, data, 1 );
return( 0 );
}
@ -123,11 +117,6 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
X86_HAVE( BMI2 ) &&
X86_HAVE( AVX2 ) )
{
if( IsAsan() )
{
__asan_verify( data, 64 );
__asan_verify( ctx, sizeof(*ctx) );
}
sha1_transform_avx2( ctx->state, data, 1 );
return( 0 );
}
@ -406,8 +395,6 @@ int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
{
if( X86_HAVE( SHA ) )
{
if( IsAsan() )
__asan_verify( input, ilen );
sha1_transform_ni( ctx->state, input, ilen / 64 );
input += ROUNDDOWN( ilen, 64 );
ilen -= ROUNDDOWN( ilen, 64 );
@ -416,8 +403,6 @@ int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
X86_HAVE( BMI2 ) &&
X86_HAVE( AVX2 ) )
{
if( IsAsan() )
__asan_verify( input, ilen );
sha1_transform_avx2( ctx->state, input, ilen / 64 );
input += ROUNDDOWN( ilen, 64 );
ilen -= ROUNDDOWN( ilen, 64 );

View file

@ -17,7 +17,6 @@
*/
#include "third_party/mbedtls/sha256.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/macros.internal.h"
#include "libc/nexgen32e/nexgen32e.h"
#include "libc/nexgen32e/sha.h"
@ -170,8 +169,6 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
X86_HAVE( SSE2 ) &&
X86_HAVE( SSSE3 ) )
{
if( IsAsan() )
__asan_verify( data, 64 );
sha256_transform_ni( ctx->state, data, 1 );
return( 0 );
}
@ -179,8 +176,6 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
X86_HAVE( AVX ) &&
X86_HAVE( AVX2 ) )
{
if( IsAsan() )
__asan_verify( data, 64 );
sha256_transform_rorx( ctx->state, data, 1 );
return( 0 );
}
@ -306,8 +301,6 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
X86_HAVE( SSE2 ) &&
X86_HAVE( SSSE3 ) )
{
if( IsAsan() )
__asan_verify( input, ilen );
sha256_transform_ni( ctx->state, input, ilen / 64 );
input += ROUNDDOWN( ilen, 64 );
ilen -= ROUNDDOWN( ilen, 64 );
@ -316,8 +309,6 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
X86_HAVE( BMI2 ) &&
X86_HAVE( AVX2 ) )
{
if( IsAsan() )
__asan_verify( input, ilen );
sha256_transform_rorx( ctx->state, input, ilen / 64 );
input += ROUNDDOWN( ilen, 64 );
ilen -= ROUNDDOWN( ilen, 64 );

View file

@ -16,7 +16,6 @@
limitations under the License.
*/
#include "third_party/mbedtls/sha512.h"
#include "libc/intrin/asan.internal.h"
#include "libc/literal.h"
#include "libc/macros.internal.h"
#include "libc/nexgen32e/nexgen32e.h"
@ -167,8 +166,6 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx,
if( !IsTiny() && X86_HAVE(AVX2) )
{
if (IsAsan())
__asan_verify(data, 128);
sha512_transform_rorx(ctx, data, 1);
return 0;
}
@ -279,7 +276,6 @@ int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx,
left = 0;
}
if (!IsTiny() && ilen >= 128 && X86_HAVE(AVX2)) {
if (IsAsan()) __asan_verify(input, ilen / 128 * 128);
sha512_transform_rorx(ctx, input, ilen / 128);
input += ROUNDDOWN(ilen, 128);
ilen -= ROUNDDOWN(ilen, 128);

View file

@ -53,7 +53,6 @@ $(THIRD_PARTY_NSYNC_A_OBJS): private \
-ffreestanding \
-fdata-sections \
-ffunction-sections \
-fno-sanitize=address \
-Wframe-larger-than=4096 \
-Walloca-larger-than=4096

View file

@ -46,7 +46,6 @@ $(THIRD_PARTY_NSYNC_MEM_A_OBJS): private \
-ffreestanding \
-fdata-sections \
-ffunction-sections \
-fno-sanitize=address \
-Wframe-larger-than=4096 \
-Walloca-larger-than=4096

View file

@ -36,7 +36,6 @@ $(THIRD_PARTY_PUFF_A).pkg: \
$(THIRD_PARTY_PUFF_A_OBJS): private \
COPTS += \
-ffreestanding \
-fno-sanitize=address \
-Wframe-larger-than=4096 \
-Walloca-larger-than=4096

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;

View file

@ -53,7 +53,6 @@ o/$(MODE)/third_party/xed/x86ild.greg.o: private \
$(THIRD_PARTY_XED_A_OBJS): private \
COPTS += \
-ffreestanding \
-fno-sanitize=address \
-Wframe-larger-than=4096 \
-Walloca-larger-than=4096