mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
MFC: r200272
Add additional checks of the kernel stack addresses in order to ensure we don't overrun the beginning of the call chain.
This commit is contained in:
parent
4904067682
commit
b7fc89b74b
2 changed files with 22 additions and 6 deletions
|
|
@ -36,15 +36,20 @@ __FBSDID("$FreeBSD$");
|
|||
#include <machine/stack.h>
|
||||
#include <machine/vmparam.h>
|
||||
|
||||
static void stack_capture(struct stack *st, struct frame *fp);
|
||||
static void stack_capture(struct stack *st, struct frame *frame);
|
||||
|
||||
static void
|
||||
stack_capture(struct stack *st, struct frame *fp)
|
||||
stack_capture(struct stack *st, struct frame *frame)
|
||||
{
|
||||
struct frame *fp;
|
||||
vm_offset_t callpc;
|
||||
|
||||
stack_zero(st);
|
||||
while (1) {
|
||||
fp = frame;
|
||||
for (;;) {
|
||||
if (!INKERNEL((vm_offset_t)fp) ||
|
||||
!ALIGNED_POINTER(fp, uint64_t))
|
||||
break;
|
||||
callpc = fp->fr_pc;
|
||||
if (!INKERNEL(callpc))
|
||||
break;
|
||||
|
|
@ -56,6 +61,9 @@ stack_capture(struct stack *st, struct frame *fp)
|
|||
break;
|
||||
if (stack_put(st, callpc) == -1)
|
||||
break;
|
||||
if (v9next_frame(fp) <= fp ||
|
||||
v9next_frame(fp) >= frame + KSTACK_PAGES * PAGE_SIZE)
|
||||
break;
|
||||
fp = v9next_frame(fp);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,20 +36,28 @@ __FBSDID("$FreeBSD$");
|
|||
#include <machine/stack.h>
|
||||
#include <machine/vmparam.h>
|
||||
|
||||
static void stack_capture(struct stack *st, struct frame *fp);
|
||||
static void stack_capture(struct stack *st, struct frame *frame);
|
||||
|
||||
static void
|
||||
stack_capture(struct stack *st, struct frame *fp)
|
||||
stack_capture(struct stack *st, struct frame *frame)
|
||||
{
|
||||
struct frame *fp;
|
||||
vm_offset_t callpc;
|
||||
|
||||
stack_zero(st);
|
||||
while (1) {
|
||||
fp = frame;
|
||||
for (;;) {
|
||||
if (!INKERNEL((vm_offset_t)fp) ||
|
||||
!ALIGNED_POINTER(fp, uint64_t))
|
||||
break;
|
||||
callpc = fp->fr_pc;
|
||||
if (!INKERNEL(callpc))
|
||||
break;
|
||||
if (stack_put(st, callpc) == -1)
|
||||
break;
|
||||
if (v9next_frame(fp) <= fp ||
|
||||
v9next_frame(fp) >= frame + KSTACK_PAGES * PAGE_SIZE)
|
||||
break;
|
||||
fp = v9next_frame(fp);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue