PR14364, PR14630: Use set_fs and pagefault_disable/enable around more accesses
It turns out there are a bunch of conceptually overlapping
functions/macros throughout the runtime, each of which attempts to
dereference untrustworthy kernel- or user-space pointers, in slightly
different ways.
When deliberately invoked with bad pointer values, some lockdep
kernels (e.g. 2.6.32-279.9.1.el6.x86_64.debug) would emit errors about
page-fault handling paths being triggered in inappropriate contexts
for some of these lookup functions. It turns out a more robust
control of address space checking and fault suppression is necessary.
* runtime/linux/autoconf-pagefault_disable.c: New test.
* buildrun.cxx (compile_pass): Run it.
* runtime/linux/copy.c (_stp_read_address): Add pagefault_{disable,enable}.
Note duplication with loc2c-runtime.h
(_stp_strncpy_from_user): Add set_fs & pagefault_{disable,enable}.
Note duplication with loc2c-runtime.h
* runtime/stp_string.h (__stp_get_user): Wrap in pagefault_{disable,enable}.
Note duplication with loc2c-runtime.h
* tapset/uconversions.stp (__STP_GET_USER): Instead of __stp_get_user,
zap duplication with loc2c-runtime.h and just call loc2c-runtime.h.
* runtime/loc2c-runtime.h (STAPCONF_PAGEFAULT_DISABLE): Add dummy
macros for pre-rhel5 kernels.
(_stp_deref, _stp_store_deref): Revamped arch-specific macros, setting
segments and disabling pagefaults.
(uderef,ustore_deref,kderef,kstore_deref): Revamped macros to call the
above. These should become the standard throughout the runtime/tapset.