platform_bionic/libc/bionic
Mitch Phillips 43d5f9d4dd Add tagged pointers to bionic.
This patch introduces tagged pointers to bionic. We add a static tag to
all pointers on arm64 compatible platforms (needs requisite
top-byte-ignore hardware feature and relevant kernel patches).

We dynamically detect TBI-compatible devices (a device with the TBI feature and
kernel support) at process start time, and insert an implementation-dependent
tag into the top byte of the pointer for all heap allocations. We then check
that the tag has not been truncated when deallocating the memory.

If an application incorrectly writes to the top byte of the pointer, we
terminate the process at time of detection. This will allow MTE-incompatible
applications to be caught early.

Bug: 135754954
Bug: 147147490

Test: cd bionic && atest .
Change-Id: I6e5b809fc81f55dd517f845eaf20f3c0ebd4d86e
2020-01-15 15:03:00 -08:00
..
scudo Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
__bionic_get_shell_path.cpp Fix internal uses of _PATH_BSHELL. 2019-03-25 17:28:22 -07:00
__cmsg_nxthdr.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
__cxa_guard.cpp Remove now unneeded #undef in __cxa_guard.cpp 2019-08-07 11:10:22 -07:00
__cxa_pure_virtual.cpp Move libc_log code into libasync_safe. 2017-05-03 08:50:43 -07:00
__cxa_thread_atexit_impl.cpp Fix dlclose for libraries with thread_local dtors 2018-01-10 10:24:06 +01:00
__errno.cpp Move errno to a pthread_internal_t field. 2018-12-11 12:59:23 -08:00
__gnu_basename.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
__libc_current_sigrtmax.cpp Make unified headers' SIGRTMIN/SIGRTMAX usable before API 21. 2017-04-26 14:34:36 -07:00
__libc_current_sigrtmin.cpp Move sigrtmin.h into platform headers. 2020-01-02 14:14:15 -08:00
__libc_init_main_thread.cpp Use ifuncs in the linker 2019-11-05 13:37:51 -08:00
__set_errno.cpp
__stack_chk_fail.cpp Move libc_log code into libasync_safe. 2017-05-03 08:50:43 -07:00
abort.cpp Generalize abort's inline_tgkill, use it in fdsan. 2018-08-31 16:39:23 -07:00
accept.cpp
access.cpp
android_set_abort_message.cpp Use PR_SET_VMA_ANON_NAME to name the abort message mapping. 2019-03-27 16:50:27 -07:00
arpa_inet.cpp
assert.cpp Remove dead longjmperror. 2017-08-23 15:40:03 -07:00
atof.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
bionic_allocator.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
bionic_arc4random.cpp Replace TLS_SLOT_BIONIC_PREINIT w/ shared globals 2018-12-04 13:51:56 -08:00
bionic_call_ifunc_resolver.cpp Use ifuncs in the linker 2019-11-05 13:37:51 -08:00
bionic_elf_tls.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
bionic_futex.cpp Support priority inheritance mutex in 64bit programs. 2018-01-24 16:11:07 -08:00
bionic_netlink.cpp Add the ScopedFd that we've never quite gotten around to. 2019-10-31 21:16:18 -07:00
bionic_netlink.h Add the ScopedFd that we've never quite gotten around to. 2019-10-31 21:16:18 -07:00
bionic_systrace.cpp Avoid calling snprintf in bionic_trace_begin. 2019-07-11 13:00:26 -07:00
bionic_time_conversions.cpp Always use CLOCK_MONOTONIC for pthreads and semaphores 2017-08-18 09:11:05 -07:00
brk.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
c16rtomb.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
c32rtomb.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
chmod.cpp
chown.cpp
clearenv.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
clock.cpp Move <sys/sysconf.h> to <bits/sysconf.h>. 2016-04-07 18:02:00 -07:00
clock_getcpuclockid.cpp Minor clock_getcpuclockid optimization. 2016-03-07 11:54:02 -08:00
clock_nanosleep.cpp Remove the ___ hack. 2019-06-19 15:38:42 -07:00
clone.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
ctype.cpp Reimplement the <ctype.h> is* functions. 2019-10-08 12:04:09 -07:00
dirent.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
dl_iterate_phdr_static.cpp Add additional dl_phdr_info fields 2019-08-22 12:43:17 -07:00
dup2.cpp
environ.cpp Mark __BIONIC_WEAK_FOR_NATIVE_BRIDGE symbols 2017-10-27 10:01:46 +02:00
error.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
ether_aton.c Fix our *ether* headers mess. 2016-05-13 11:00:22 -07:00
ether_ntoa.c Fix our *ether* headers mess. 2016-05-13 11:00:22 -07:00
eventfd_read.cpp
eventfd_write.cpp
exec.cpp Fix internal uses of _PATH_BSHELL. 2019-03-25 17:28:22 -07:00
faccessat.cpp Remove the ___ hack. 2019-06-19 15:38:42 -07:00
fchmod.cpp Remove the ___ hack. 2019-06-19 15:38:42 -07:00
fchmodat.cpp Add the ScopedFd that we've never quite gotten around to. 2019-10-31 21:16:18 -07:00
fdsan.cpp Move sigrtmin.h into platform headers. 2020-01-02 14:14:15 -08:00
ffs.cpp
fgetxattr.cpp Remove the ___ hack. 2019-06-19 15:38:42 -07:00
flistxattr.cpp Remove the ___ hack. 2019-06-19 15:38:42 -07:00
flockfile.cpp
fork.cpp Name stack+tls VMAs with PR_SET_VMA_ANON_NAME 2019-07-23 02:06:51 +00:00
fortify.cpp Fix OOB read in fortify str[np]cpy implementations found by hwasan. 2019-08-08 18:54:31 -07:00
fpclassify.cpp Remove some legacy declarations from <math.h>. 2017-10-19 14:15:31 -07:00
fsetxattr.cpp Remove the ___ hack. 2019-06-19 15:38:42 -07:00
ftruncate.cpp
fts.c Fix various ftw/nftw "shall fail"s from POSIX. 2018-05-08 15:20:07 -07:00
ftw.cpp Fix various ftw/nftw "shall fail"s from POSIX. 2018-05-08 15:20:07 -07:00
futimens.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
get_device_api_level.cpp Add android_get_device_api_level. 2018-09-06 14:19:46 -07:00
getauxval.cpp Use ifuncs in the linker 2019-11-05 13:37:51 -08:00
getcwd.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
getdomainname.cpp Add {get,set}domainname(2) 2016-03-25 14:16:58 -07:00
getentropy.cpp Add the ScopedFd that we've never quite gotten around to. 2019-10-31 21:16:18 -07:00
gethostname.cpp
getloadavg.cpp Add getloadavg(3). 2018-10-23 11:23:00 -07:00
getpagesize.cpp Break up the rest of stubs.cpp. 2016-04-06 08:34:58 -07:00
getpgrp.cpp
getpid.cpp Introduce api to track fd ownership in libc. 2018-07-19 14:28:54 -07:00
getpriority.cpp Fix getpriority/setpriority types. 2016-11-29 15:14:11 -08:00
gettid.cpp Shave another uninteresting stack frame off aborts. 2017-06-20 14:58:16 -07:00
grp_pwd.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
grp_pwd_file.cpp Add the ScopedFd that we've never quite gotten around to. 2019-10-31 21:16:18 -07:00
grp_pwd_file.h Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
iconv.cpp Add missing includes. 2017-10-11 11:25:52 -07:00
icu.cpp Eliminate ICU's .dat lookup from bionic 2019-02-06 20:49:03 +00:00
icu_static.cpp Add libc_nopthread. 2017-10-16 21:31:37 -07:00
icu_wrappers.cpp Implement wcwidth(3) in terms of icu4c. 2017-07-27 17:08:24 -07:00
ifaddrs.cpp Fix google-explicit-constructor warnings. 2016-05-03 12:08:05 -07:00
initgroups.c
inotify_init.cpp
ioctl.cpp
isatty.c
jemalloc.h Rename iterate to malloc_iterate internally. 2019-11-08 11:49:14 -08:00
jemalloc_wrapper.cpp Fix allocations escaping malloc debug. 2019-11-06 10:42:42 -08:00
killpg.cpp Replace killpg. 2017-07-11 15:00:17 -07:00
langinfo.cpp Implement <langinfo.h>. 2016-11-19 11:46:54 -08:00
lchown.cpp
legacy_32_bit_support.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
lfs64_support.cpp
libc_init_common.cpp Add tagged pointers to bionic. 2020-01-15 15:03:00 -08:00
libc_init_common.h Init fork handler after __libc_init_malloc. 2019-11-14 16:02:09 -08:00
libc_init_dynamic.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
libc_init_static.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
libgen.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
link.cpp
locale.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
lockf.cpp
lstat.cpp
malloc_common.cpp Add tagged pointers to bionic. 2020-01-15 15:03:00 -08:00
malloc_common.h Add support for scudo svelte. 2019-12-16 16:22:55 -08:00
malloc_common_dynamic.cpp Revert "Enable the scudo native allocator." 2019-12-19 19:09:59 +00:00
malloc_common_dynamic.h Add a platform API for setting an allocation limit. 2019-03-15 10:54:55 -07:00
malloc_heapprofd.cpp Rename iterate to malloc_iterate internally. 2019-11-08 11:49:14 -08:00
malloc_heapprofd.h Add a platform API for setting an allocation limit. 2019-03-15 10:54:55 -07:00
malloc_limit.cpp Rename iterate to malloc_iterate internally. 2019-11-08 11:49:14 -08:00
malloc_limit.h Add a platform API for setting an allocation limit. 2019-03-15 10:54:55 -07:00
malloc_tagged_pointers.h Add tagged pointers to bionic. 2020-01-15 15:03:00 -08:00
mblen.cpp Implement mblen(3). 2016-04-28 16:41:29 -07:00
mbrtoc16.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
mbrtoc32.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
memmem.cpp libc: add const-correct string.h overloads 2017-04-05 13:17:07 -07:00
mempcpy.cpp
mkdir.cpp
mkfifo.cpp
mknod.cpp
mmap.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
mntent.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
mremap.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
ndk_cruft.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
ndk_cruft_data.cpp Optimize tolower(3)/toupper(3) from <ctype.h>. 2019-09-27 14:42:39 -07:00
net_if.cpp Add the ScopedFd that we've never quite gotten around to. 2019-10-31 21:16:18 -07:00
netdb.cpp Complete <netdb.h>. 2017-10-15 10:37:51 -07:00
NetdClient.cpp libnetd_client: support hooking sendto/sendmsg/sendmmsg too. 2019-06-20 08:32:24 -07:00
NetdClientDispatch.cpp libnetd_client: support hooking sendto/sendmsg/sendmmsg too. 2019-06-20 08:32:24 -07:00
netinet_in.cpp POSIX says IPPORT_RESERVED is in <netdb.h>. 2016-08-12 10:38:35 -07:00
new.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
nl_types.cpp Add trivial no-op <nl_types.h>. 2016-04-06 17:22:44 -07:00
open.cpp libc: remove now-unused FORTIFY functions 2019-10-07 19:09:38 -07:00
pathconf.cpp Clean up <sys/limits.h> a bit. 2016-11-30 09:06:53 -08:00
pause.cpp Add sigset64_t and accompanying functions. 2018-01-30 18:47:16 -08:00
pipe.cpp
poll.cpp Move sigrtmin.h into platform headers. 2020-01-02 14:14:15 -08:00
posix_fadvise.cpp
posix_fallocate.cpp
posix_madvise.cpp
posix_timers.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
pthread_atfork.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
pthread_attr.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
pthread_barrier.cpp Fix pthread_barrierattr_getpshared prototype. 2016-08-11 23:18:13 -07:00
pthread_cond.cpp Fix pthread_cond_clockwait() when cond is initialized with CLOCK_MONOTONIC 2019-07-17 10:46:47 -07:00
pthread_create.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
pthread_detach.cpp Pass caller names to __pthread_internal_find for better errors. 2019-02-01 16:31:10 -08:00
pthread_equal.cpp
pthread_exit.cpp Implement dynamic TLS accesses and allocation 2019-01-25 17:53:01 -08:00
pthread_getcpuclockid.cpp Make more pthread functions weak for native bridge 2019-09-25 16:55:47 +02:00
pthread_getschedparam.cpp Make pthread_get/setschedparam weak for native bridge 2019-04-25 16:43:24 +02:00
pthread_gettid_np.cpp Pass caller names to __pthread_internal_find for better errors. 2019-02-01 16:31:10 -08:00
pthread_internal.cpp Stop using the __ANDROID_API_x__ constants. 2019-12-20 13:26:14 -08:00
pthread_internal.h Block signals in pthread_create. 2019-10-07 15:37:26 -07:00
pthread_join.cpp Pass caller names to __pthread_internal_find for better errors. 2019-02-01 16:31:10 -08:00
pthread_key.cpp Reorganize static TLS memory for ELF TLS 2019-01-11 15:34:22 -08:00
pthread_kill.cpp Make more pthread functions weak for native bridge 2019-09-25 16:55:47 +02:00
pthread_mutex.cpp Stop using the __ANDROID_API_x__ constants. 2019-12-20 13:26:14 -08:00
pthread_once.cpp
pthread_rwlock.cpp Implement new clock wait functions 2019-07-15 09:06:19 -07:00
pthread_self.cpp
pthread_setname_np.cpp Make more pthread functions weak for native bridge 2019-09-25 16:55:47 +02:00
pthread_setschedparam.cpp Make pthread_get/setschedparam weak for native bridge 2019-04-25 16:43:24 +02:00
pthread_sigqueue.cpp Make more pthread functions weak for native bridge 2019-09-25 16:55:47 +02:00
pthread_spinlock.cpp
ptrace.cpp
pty.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
pututline.c
raise.cpp Make raise/abort work with stale cached pid/tid values. 2017-05-10 16:42:04 -07:00
rand.cpp
readlink.cpp Remove outdated _FORTIFY_SOURCE #undefs 2017-07-21 11:25:52 -07:00
reboot.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
recv.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
rename.cpp
rmdir.cpp
scandir.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
sched_cpualloc.c bionic: fix assorted static analyzer warnings 2017-06-28 15:03:15 -07:00
sched_cpucount.c Type of second __sched_cpucount should be "const cpu_set_t*". 2018-04-13 16:07:21 -07:00
sched_getaffinity.cpp
sched_getcpu.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
scudo.h Add support for scudo svelte. 2019-12-16 16:22:55 -08:00
scudo_wrapper.cpp Call __libc_init_malloc from scudo. 2019-11-15 08:42:03 -08:00
semaphore.cpp Stop using the __ANDROID_API_x__ constants. 2019-12-20 13:26:14 -08:00
send.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
setegid.cpp
seteuid.cpp
setjmp_cookie.cpp Replace TLS_SLOT_BIONIC_PREINIT w/ shared globals 2018-12-04 13:51:56 -08:00
setpgrp.cpp
sigaction.cpp Move sigrtmin.h into platform headers. 2020-01-02 14:14:15 -08:00
signal.cpp Move sigrtmin.h into platform headers. 2020-01-02 14:14:15 -08:00
sigprocmask.cpp Move sigrtmin.h into platform headers. 2020-01-02 14:14:15 -08:00
sleep.cpp sleep/usleep: switch to trivial implementations. 2019-10-28 22:25:02 -07:00
spawn.cpp Introduce api to track fd ownership in libc. 2018-07-19 14:28:54 -07:00
stat.cpp
stdlib_l.cpp Move non-locale.h APIs out of locale.cpp. 2017-07-12 12:41:47 -07:00
strchr.cpp Remove outdated _FORTIFY_SOURCE #undefs 2017-07-21 11:25:52 -07:00
strchrnul.cpp
strerror.cpp Reduce strerror(3)'s impact on .data.rel.ro. 2018-12-03 08:46:21 -08:00
string_l.cpp Move non-locale.h APIs out of locale.cpp. 2017-07-12 12:41:47 -07:00
strings_l.cpp Move non-locale.h APIs out of locale.cpp. 2017-07-12 12:41:47 -07:00
strnlen.c
strrchr.cpp Remove outdated _FORTIFY_SOURCE #undefs 2017-07-21 11:25:52 -07:00
strsignal.cpp Workaround string-plus-int warning 2019-02-28 15:54:58 -08:00
strtol.cpp Simplify atoi*/strto* for signed integers. 2017-12-21 17:44:22 -08:00
strtold.cpp Use __RENAME for long double functions. 2017-09-14 16:10:43 -07:00
swab.cpp Add POSIX swab. 2017-10-18 13:34:32 -07:00
symlink.cpp
sync_file_range.cpp Add sync_file_range to <fcntl.h>. 2016-04-05 12:17:22 -07:00
sys_epoll.cpp Add sigset64_t and accompanying functions. 2018-01-30 18:47:16 -08:00
sys_msg.cpp [mips64] Fix ipc syscalls 2016-09-09 12:24:04 +02:00
sys_sem.cpp [mips64] Fix ipc syscalls 2016-09-09 12:24:04 +02:00
sys_shm.cpp [mips64] Fix ipc syscalls 2016-09-09 12:24:04 +02:00
sys_signalfd.cpp Add sigset64_t and accompanying functions. 2018-01-30 18:47:16 -08:00
sys_statfs.cpp Support statvfs on API levels before 19. 2019-08-29 21:57:58 -07:00
sys_statvfs.cpp Support statvfs on API levels before 19. 2019-08-29 21:57:58 -07:00
sys_time.cpp Add futimes, futimesat, and lutimes. 2016-06-08 19:51:20 -07:00
sysconf.cpp sysconf(_SC_ARG_MAX): go back to imitating the kernel. 2019-11-15 09:24:35 -08:00
sysinfo.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
syslog.cpp Add the %m GNU extension to printf/wprintf. 2018-08-30 16:00:42 -07:00
system.cpp Fix internal uses of _PATH_BSHELL. 2019-03-25 17:28:22 -07:00
system_property_api.cpp Revert "Revert "Make system property reads wait-free"" 2019-11-12 20:41:55 +00:00
system_property_set.cpp Move bionic_macros.h from private to platform. 2020-01-02 14:09:50 -08:00
tdestroy.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
termios.cpp Make inline tcsetattr definition match constants. 2017-07-05 12:00:29 -07:00
thread_private.cpp Reimplement popen(3)/pclose(3). 2018-07-11 12:15:26 -07:00
threads.cpp threads.h: Add C11 thread support. 2019-04-24 09:12:29 -07:00
time64.c
time64_config.h
timespec_get.cpp Add C11 timespec_get. 2018-07-17 13:21:05 -07:00
tmpfile.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
umount.cpp
unlink.cpp
usleep.cpp sleep/usleep: switch to trivial implementations. 2019-10-28 22:25:02 -07:00
vdso.cpp Replace TLS_SLOT_BIONIC_PREINIT w/ shared globals 2018-12-04 13:51:56 -08:00
wait.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
wchar.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
wchar_l.cpp Add remaining _l function stubs. 2018-02-13 23:14:12 -08:00
wcstod.cpp Modernize codebase by replacing NULL with nullptr 2018-08-02 18:09:44 -07:00
wctype.cpp Optimize tolower(3)/toupper(3) from <ctype.h>. 2019-09-27 14:42:39 -07:00
wcwidth.cpp Implement wcwidth(3) in terms of icu4c. 2017-07-27 17:08:24 -07:00
wmempcpy.cpp