[PATCH] D57179: Enhance support for NetBSD in SafeStack
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 24 13:30:28 PST 2019
vitalybuka accepted this revision.
vitalybuka added inline comments.
This revision is now accepted and ready to land.
================
Comment at: lib/safestack/safestack_platform.h:97
#if SANITIZER_NETBSD
- return mmap(addr, length, prot, flags, fd, offset);
+ SFS_CHECK(&__mmap);
+ return __mmap(addr, length, prot, flags, fd, 0, offset);
----------------
This SFS_CHECK (like the on in sanitizer_common) is not useful with or without weak
It will crash anyway with obvious stack on null pointer.
================
Comment at: lib/safestack/safestack_platform.h:116
inline int Mprotect(void *addr, size_t length, int prot) {
#if SANITIZER_NETBSD
+ DEFINE__REAL(int, mprotect, void *a, size_t b, int c);
----------------
krytarowski wrote:
> vitalybuka wrote:
> > We don't want to hit interpector here, because it can be called called from preinit_array.
> > DEFINE__REAL will avoid interceptors, however dlsym from preinit_array may crash as it can to try to allocate memory.
> > So we use syscall on linux.
> > sanitizer_common/sanitizer_netbsd still had such problem, so I didn't bother to copy DEFINE_REAL.
> >
> NetBSD does not use/support `preinit_array`, except on archs that demand it (amd64/i386 aren't in the set).
>
> How does it crash with allocating the memory? By calling real malloc? Dynamic loader on NetBSD uses its internal copy of xmalloc() for allocations.
>
> According to my quick testing with gdb(1) and an example program, dlsym(3) does not allocate anything through xmalloc() (at least for RTLD_SELF).
Yes, on linux it crashes with malloc which can be not initialized (if its non standard allocator)
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57179/new/
https://reviews.llvm.org/D57179
More information about the llvm-commits
mailing list