Re: [PATCH] makedumpfile: call initial before use cache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yes, it works!
Thank you so much!

On Mon, Jul 22, 2024 at 2:46 PM HAGIO KAZUHITO(萩尾 一仁)
<k-hagio-ab@xxxxxxx> wrote:
>
> On 2024/07/20 16:38, Lichen Liu wrote:
>
> >> This will work only for 4.19 and later kernels, but might reduce users
> >> that hit the issue.  Does this work for you?
> > That works for me because I'm testing for the 6.x kernel.
>
> Thanks for the check.  Is the issue a segmentation fault?
> I've made a patch below, is this OK?
>
>
>  From 084742cba5b81da563074454ab8c879e8e411cb0 Mon Sep 17 00:00:00 2001
> From: Kazuhito Hagio <k-hagio-ab@xxxxxxx>
> Date: Mon, 22 Jul 2024 14:31:43 +0900
> Subject: [PATCH] Workaround for segfault by "makedumpfile --mem-usage" on PPC64
>
> "makedumpfile --mem-usage /proc/kcore" can cause a segmentation fault on
> PPC64, because the readmem() of the following code path uses cache
> before it's initialized in initial().
>
>    show_mem_usage
>      get_page_offset
>        get_versiondep_info_ppc64
>          readmem
>      ...
>      initial
>          cache_init
>
> The get_page_offset() is needed to get vmcoreinfo from /proc/kcore data,
> so we can avoid calling it when a vmcoreinfo exists in the ELF NOTE
> segment of /proc/kcore, i.e. on Linux 4.19 and later.
>
> (Note: for older kernels, we will need another way to fix it.)
>
> Reported-by: Lichen Liu <lichliu@xxxxxxxxxx>
> Signed-off-by: Kazuhito Hagio <k-hagio-ab@xxxxxxx>
> ---
>   makedumpfile.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/makedumpfile.c b/makedumpfile.c
> index 5b347126db76..7d1dfcca50d8 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -12019,14 +12019,14 @@ int show_mem_usage(void)
>                 DEBUG_MSG("Read vmcoreinfo from NOTE segment: %d\n", vmcoreinfo);
>         }
>
> -       if (!get_page_offset())
> -               return FALSE;
> +       if (!vmcoreinfo) {
> +               if (!get_page_offset())
> +                       return FALSE;
>
> -       /* paddr_to_vaddr() on arm64 needs phys_base. */
> -       if (!get_phys_base())
> -               return FALSE;
> +               /* paddr_to_vaddr() on arm64 needs phys_base. */
> +               if (!get_phys_base())
> +                       return FALSE;
>
> -       if (!vmcoreinfo) {
>                 if (!get_sys_kernel_vmcoreinfo(&vmcoreinfo_addr, &vmcoreinfo_len))
>                         return FALSE;
>
> --
> 2.31.1


_______________________________________________
kexec mailing list
kexec@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux