riscv db_trace: Ensure trapframe pointer is suitably aligned.

Suggested by:	jrtc27
Reviewed by:	jrtc27
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D41534
This commit is contained in:
John Baldwin 2023-08-21 21:00:26 -07:00
parent 682d5a87e5
commit 7ccaf76a27

View File

@ -84,7 +84,8 @@ db_stack_trace_cmd(struct thread *td, struct unwind_state *frame)
struct trapframe *tf;
tf = (struct trapframe *)(uintptr_t)frame->sp;
if (!kstack_contains(td, (vm_offset_t)tf,
if (!__is_aligned(tf, _Alignof(*tf)) ||
!kstack_contains(td, (vm_offset_t)tf,
sizeof(*tf))) {
db_printf("--- invalid trapframe %p\n", tf);
break;