f3968e89cb
This patch introduces GWP-ASan - a sampled allocator framework that finds use-after-free and heap-buffer-overflow bugs in production environments. GWP-ASan is being introduced in an always-disabled mode. This means that GWP-ASan will be permanently disabled until a further patch turns on support. As such, there should be no visible functional change for the time being. GWP-ASan requires -fno-emulated-tls wherever it's linked from. We intentionally link GWP-ASan into libc so that it's part of the initial set of libraries, and thus has static TLS storage (so we can use Initial-Exec TLS instead of Global-Dynamic). As a benefit, this reduces overhead for a sampled process. GWP-ASan is always initialised via. a call to mallopt(M_INITIALIZE_GWP_ASAN, which must be done before a process is multithreaded). More information about GWP-ASan can be found in the upstream documentation: http://llvm.org/docs/GwpAsan.html Bug: 135634846 Test: atest bionic Change-Id: Ib9bd33337d17dab39ac32f4536bff71bd23498b0
50 lines
2.1 KiB
C
50 lines
2.1 KiB
C
/*
|
|
* Copyright (C) 2019 The Android Open Source Project
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* * Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in
|
|
* the documentation and/or other materials provided with the
|
|
* distribution.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <pthread.h>
|
|
#include <stdatomic.h>
|
|
|
|
#include <private/bionic_globals.h>
|
|
#include <private/bionic_malloc_dispatch.h>
|
|
|
|
// Function prototypes.
|
|
bool InitSharedLibrary(void* impl_handle, const char* shared_lib, const char* prefix,
|
|
MallocDispatch* dispatch_table);
|
|
|
|
void* LoadSharedLibrary(const char* shared_lib, const char* prefix, MallocDispatch* dispatch_table);
|
|
|
|
bool FinishInstallHooks(libc_globals* globals, const char* options, const char* prefix);
|
|
|
|
// Lock for globals, to guarantee that only one thread is doing a mutate.
|
|
extern pthread_mutex_t gGlobalsMutateLock;
|
|
extern _Atomic bool gGlobalsMutating;
|
|
|
|
// Function hooks instantiations, used by dispatch-table allocators to install themselves.
|
|
void SetGlobalFunctions(void* functions[]);
|