Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Apr 2024 20:25:39 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 402c6c331d73 - stable/13 - riscv db_trace: Ensure trapframe pointer is suitably aligned.
Message-ID:  <202404082025.438KPdvv039379@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=402c6c331d73491e5cc711336a7ec23fcc87d03c

commit 402c6c331d73491e5cc711336a7ec23fcc87d03c
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-08-22 04:00:26 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-04-08 17:29:34 +0000

    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
    
    (cherry picked from commit 7ccaf76a27f138bde3f2b162a9c8ebb6216c05bc)
---
 sys/riscv/riscv/db_trace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/riscv/riscv/db_trace.c b/sys/riscv/riscv/db_trace.c
index 00ec1a750e33..12972839c29d 100644
--- a/sys/riscv/riscv/db_trace.c
+++ b/sys/riscv/riscv/db_trace.c
@@ -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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404082025.438KPdvv039379>