Tighten frame pointer checking in DTrace's amd64 stack unwinder.
Avoid assuming that the kernel was compiled with -fno-omit-frame-pointer. MFC after: 1 week Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc.
This commit is contained in:
parent
8d4b1e3b76
commit
fcc0db1734
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=365048
@ -56,6 +56,7 @@ void
|
||||
dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
|
||||
uint32_t *intrpc)
|
||||
{
|
||||
struct thread *td;
|
||||
int depth = 0;
|
||||
register_t rbp;
|
||||
struct amd64_frame *frame;
|
||||
@ -70,10 +71,16 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
|
||||
__asm __volatile("movq %%rbp,%0" : "=r" (rbp));
|
||||
|
||||
frame = (struct amd64_frame *)rbp;
|
||||
td = curthread;
|
||||
while (depth < pcstack_limit) {
|
||||
if (!INKERNEL((long) frame))
|
||||
break;
|
||||
|
||||
if ((vm_offset_t)frame >=
|
||||
td->td_kstack + ptoa(td->td_kstack_pages) ||
|
||||
(vm_offset_t)frame < td->td_kstack)
|
||||
break;
|
||||
|
||||
callpc = frame->f_retaddr;
|
||||
|
||||
if (!INKERNEL(callpc))
|
||||
@ -84,14 +91,11 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
|
||||
if ((aframes == 0) && (caller != 0)) {
|
||||
pcstack[depth++] = caller;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pcstack[depth++] = callpc;
|
||||
}
|
||||
|
||||
if (frame->f_frame <= frame ||
|
||||
(vm_offset_t)frame->f_frame >= curthread->td_kstack +
|
||||
curthread->td_kstack_pages * PAGE_SIZE)
|
||||
if ((vm_offset_t)frame->f_frame <= (vm_offset_t)frame)
|
||||
break;
|
||||
frame = frame->f_frame;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user