[Crash-utility] [External Mail][ANNOUNCE] crash gcore command, version 1.6.0 is released
Vincent Whitchurch
vincent.whitchurch at axis.com
Tue Nov 9 12:55:00 UTC 2021
On Thu, Nov 12, 2020 at 01:29:06PM +0100, 赵乾利 wrote:
> gcore patch:
> commit 837182cc6589095c0d08f71f57953c50ad61cc19
> Author: zhaoqianli <zhaoqianli at xiaomi.com>
> Date: Thu Nov 12 19:41:01 2020 +0800
>
> Fix register parsing error caused by miscalculation of the
> starting address of the pt_regs structure on the kernel stack
>
> Signed-off-by: zhaoqianli <zhaoqianli at xiaomi.com>
>
> diff --git a/libgcore/gcore_arm64.c b/libgcore/gcore_arm64.c
> index 3257389..c828fee 100644
> --- a/libgcore/gcore_arm64.c
> +++ b/libgcore/gcore_arm64.c
> @@ -28,7 +28,7 @@ static int gpr_get(struct task_context *target,
>
> BZERO(regs, sizeof(*regs));
>
> - readmem(machdep->get_stacktop(target->task) - 16 - SIZE(pt_regs), KVADDR,
> + readmem(machdep->get_stacktop(target->task) - machdep->machspec->user_eframe_offset, KVADDR,
> regs, sizeof(struct user_pt_regs), "gpr_get: user_pt_regs",
> gcore_verbose_error_handle());
>
> @@ -124,7 +124,7 @@ static int compat_gpr_get(struct task_context *target,
> BZERO(&pt_regs, sizeof(pt_regs));
> BZERO(regs, sizeof(*regs));
>
> - readmem(machdep->get_stacktop(target->task) - 16 - SIZE(pt_regs), KVADDR,
> + readmem(machdep->get_stacktop(target->task) - machdep->machspec->user_eframe_offset, KVADDR,
> &pt_regs, sizeof(struct pt_regs), "compat_gpr_get: pt_regs",
> gcore_verbose_error_handle());
The above patch was correct, but it looks like the version that actually
landed in the crash-gcore git[0] has a small error. The version in the
git retains the "- SIZE(pt_regs)" but that should have been be removed
as can be seen in the patch above.
[0] https://github.com/fujitsu/crash-gcore/commit/19bfb92e50799a82f7ce6179fb35ccd82061bafd)
So a fix like the below is needed to get valid registers:
8<--------------
>From f841c41725fbab3cd4247555a550b496b57eb2a6 Mon Sep 17 00:00:00 2001
From: Vincent Whitchurch <vincent.whitchurch at axis.com>
Date: Tue, 9 Nov 2021 13:45:42 +0100
Subject: [PATCH] arm64: Fix pt_regs miscalculation
The user_eframe_offset includes the SIZE(pt_regs) so that should have
been removed in commit 19bfb92e50799a82f7ce6179fb35ccd82061bafd ("arm64:
Fix miscalculation of the starting address...") but that removal appears
to have got lost.
Signed-off-by: Vincent Whitchurch <vincent.whitchurch at axis.com>
---
src/libgcore/gcore_arm64.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/libgcore/gcore_arm64.c b/src/libgcore/gcore_arm64.c
index 678da8d..da9c647 100644
--- a/src/libgcore/gcore_arm64.c
+++ b/src/libgcore/gcore_arm64.c
@@ -29,7 +29,7 @@ static int gpr_get(struct task_context *target,
BZERO(regs, sizeof(*regs));
readmem(machdep->get_stacktop(target->task) -
- machdep->machspec->user_eframe_offset - SIZE(pt_regs), KVADDR,
+ machdep->machspec->user_eframe_offset, KVADDR,
regs, sizeof(struct user_pt_regs), "gpr_get: user_pt_regs",
gcore_verbose_error_handle());
@@ -126,7 +126,7 @@ static int compat_gpr_get(struct task_context *target,
BZERO(regs, sizeof(*regs));
readmem(machdep->get_stacktop(target->task) -
- machdep->machspec->user_eframe_offset - SIZE(pt_regs), KVADDR,
+ machdep->machspec->user_eframe_offset, KVADDR,
&pt_regs, sizeof(struct pt_regs), "compat_gpr_get: pt_regs",
gcore_verbose_error_handle());
--
2.28.0
More information about the Crash-utility
mailing list