On Thu, Nov 12, 2020 at 01:29:06PM +0100, ?乾利 wrote:
> gcore patch:
> commit 837182cc6589095c0d08f71f57953c50ad61cc19
> Author: zhaoqianli <zhaoqianli(a)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(a)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/19bfb92e50799a82f7ce6179fb3...)
So a fix like the below is needed to get valid registers:
Thanks for your report.
I know this issue. Zhao's patch was originally correct but I made
mistake and broke it when I merged it into the local repository
at that time.
I also know there is already another PR to fix this issue on github.
Anyway, next version will include fix for this issue.
Thanks.
HATAYAMA, Daisuke