1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-02-08 09:33:16 +00:00

Check alignment of fp in unwind_frame

A misaligned frame pointer is certainly not a valid frame pointer and
with strict alignment enabled (as on CHERI) can cause panics when it is
loaded from later in the code.

Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D34646
This commit is contained in:
Dapeng Gao 2022-11-15 00:21:38 +00:00 committed by Brooks Davis
parent c72f259727
commit 40e0fa10f5
2 changed files with 4 additions and 2 deletions

View File

@ -41,7 +41,8 @@ unwind_frame(struct thread *td, struct unwind_state *frame)
fp = frame->fp;
if (!kstack_contains(td, fp, sizeof(uintptr_t) * 2))
if (!is_aligned(fp, sizeof(fp)) ||
!kstack_contains(td, fp, sizeof(fp) * 2))
return (false);
/* FP to previous frame (X29) */

View File

@ -47,7 +47,8 @@ unwind_frame(struct thread *td, struct unwind_state *frame)
fp = frame->fp;
if (!kstack_contains(td, fp - sizeof(fp) * 2, sizeof(fp) * 2))
if (!is_aligned(fp, sizeof(fp)) ||
!kstack_contains(td, fp - sizeof(fp) * 2, sizeof(fp) * 2))
return (false);
frame->sp = fp;