dtrace: update getufpstack implementation to be safer
The dtrace_getufpstack() function was a death trap when called for cases where
current happened to be in a transitional state (no mm) or a kthread. It was
also using find_vma() when that was not quite necessary. Finally, it was not
correctly using the saved stack pointer from userspace correctly (in one place
it used old_rsp as appropriate, but in another p->thread.usersp). The code
has been rewritten to make use of the fact that the only valid stack addresses
that can be in use when this function is called must appear between the current
stack pointer position (old_rsp) and the bottom of the stack (mm->start_stack).
Therefore, no vma is necessary anymore.
The new implementation also ensures that when there is no mm, or we're dealing
with a kthread, the resulting data is still formatted correctly, i.e. with a
PID in the first slot, and zeros in all other slots.
This commit effectively builds on top of the fix applied by Nick Alcock.
Orabug:
17591351
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>