diff options
author | Ian Moffett <ian@osmora.org> | 2025-08-06 00:16:18 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-08-06 00:16:18 -0400 |
commit | 0f4c69de13f711a7353a7d7e04f3fe377a728765 (patch) | |
tree | a468b40c0d4916e4467ac852d89d8da541f1396e | |
parent | 21a03190ec1dd295b2020667ff80aaf8504ce177 (diff) |
kernel/amd64: Add better checks on 'rbp' and 'rip'
Improve handling within the stacktrace logic used during system panics
and critical events.
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 19dcf44..b6431b8 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -268,13 +268,16 @@ md_backtrace(void) while (1) { rip = rbp[1]; rbp = (uintptr_t *)rbp[0]; - name = backtrace_addr_to_name(rip, &off); - if (rbp == NULL) + /* + * This is not a valid value, get out + * of this loop!! + */ + if (rbp == NULL || rip == 0) { break; - if (name == NULL) - name = "???"; + } + name = backtrace_addr_to_name(rip, &off); snprintf(line, sizeof(line), "%p @ <%s+0x%x>\n", rip, name, off); cons_putstr(&g_root_scr, line, strlen(line)); } |