On Sat, 04 Sep 2021 11:36:33 +0200, Greg Steuck wrote:
> This brings me to the "what's next" part. Obviously the mmap
> interception needs to be fixed to get anywhere. MmapNamed invokes
> internal_mmap which is defined in sanitizer_openbsd.cpp as:
>
> uptr internal_mmap(void *addr, size_t length, int prot, int flags, int fd,
> u64 offset) {
> return (uptr)mmap(addr, length, prot, flags, fd, offset);
> }
>
> This sadly can't work because mmap in sanitizer_common_interceptors.inc
> calls internal_mmap if !asan_inited and hence the endless
> recursion. Other systems have alternative ways of reaching the original
> libc mmap. E.g. directly calling mmap syscall in sanitizer_linux.cpp or
> calling __mmap in sanitizer_netbsd.cpp. Neither of these seems to be
> available on OpenBSD. So, what can we do to interpose mmap?
The simplest approach is probably to use _thread_sys_mmap() instead.
That is a strong alias for the hidden _libc_mmap() function.
- todd