[PATCH] x86_64: fix mincore_validate
[PATCH] x86_64: fix mincore_validate

The detection logic introduced in 28f33c8ce0b654cf31d6beda9a612870662f3c56 is
broken, because it tests mincore using an address that is almost certainly not
page-aligned. straces confirms that msync is used all the time.

This patch fixes the logic by page-aligning the test pointer. strace now shows
that mincore is actually used. Furthermore, the return value of mincore is not
sufficient to assess whether the address can be safely dereferenced: we should
also check that the pages are mapped, through the passed mvec array. This patch
also adds this verification.

Tested on a system where unwinding a stack across a JNI boundary would cause
sporadic segfaults; no more crashes were observed after the patch.

rantala/libunwind,krytarowski/libunwind,yuyichao/libunwind,libunwind/libunwind,yuyichao/libunwind,frida/libunwind,rantala/libunwind,unkadoug/libunwind,frida/libunwind,krytarowski/libunwind,unkadoug/libunwind,djwatson/libunwind,libunwind/libunwind,djwatson/libunwind,frida/libunwind,vtjnash/libunwind,tkelman/libunwind,djwatson/libunwind,rantala/libunwind,libunwind/libunwind,tkelman/libunwind,vtjnash/libunwind,yuyichao/libunwind,tkelman/libunwind,vtjnash/libunwind,unkadoug/libunwind,krytarowski/libunwind