Thank you for the patch, XingYang.

On Sun, Sep 22, 2024 at 1:08 AM <r...@lists.crash-utility.osci.io> wrote:

> From: 1127955...@qq.com
> To: devel@lists.crash-utility.osci.io, l...@redhat.com
> Cc: Li XingYang <1127955...@qq.com>, Zach Wade <zachwad...@gmail.com>
> Bcc:
> Date: Sun, 22 Sep 2024 01:00:29 +0800
> Subject: [PATCH] X86 64: fix the method for determining whether to enable
> kalsr
> From: Li XingYang <1127955...@qq.com>
>
> The recently commit 6752571d8d78 fixed the issue where linux kernel with
> 223b5e57d0d5 ("mm/execmem, arch: convert remaining overrides of
> module_alloc to execmem")
> could not load crash, but it did not work in the following two situations:
> 1: Kernel enables KASAN
> 2: The kernel set CONFIG_RANDOMIZE_BASE but not set CONFIG_RANDOMIZE_MEMORY
>
> crash: seek error: kernel virtual address: ffffffff826bb418  type:
> "page_offset_base"
>
> In both cases, kaslr_regions will not be exported in /proc/kallsyms,
> but kaslr_get_random_long will still be exported in /proc/kallsyms.
> So use kaslr_get_random_long instead of kaslr_degions
> Determine whether to enable kalsr
>

The kaslr_get_random_long() is not exported by EXPORT_SYMBOL(), not sure if
this could be optimized out(elimited) by the compiler, we have observed the
kaslr_regions symbol could be optimized out in some kernels.

But anyway, I do not have a better solution for the time being. So I agree
to this change: Ack.



BTW:  The following functions in the kernel really misled me.
static inline bool kaslr_enabled(void)
{
        return IS_ENABLED(CONFIG_RANDOMIZE_MEMORY) &&
                !!(boot_params.hdr.loadflags & KASLR_FLAG);
}

/*
 * Apply no randomization if KASLR was disabled at boot or if KASAN
 * is enabled. KASAN shadow mappings rely on regions being PGD aligned.
 */
static inline bool kaslr_memory_enabled(void)
{
        return kaslr_enabled() && !IS_ENABLED(CONFIG_KASAN);
}


Thanks
Lianbo


> Signed-off-by: Li XingYang <1127955...@qq.com>
> Signed-off-by: Zach Wade <zachwad...@gmail.com>
> ---
>  symbols.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/symbols.c b/symbols.c
> index 69a1fbb..02359a4 100644
> --- a/symbols.c
> +++ b/symbols.c
> @@ -619,7 +619,7 @@ strip_symbol_end(const char *name, char *buf)
>   *  or in /proc/kallsyms on a live system.
>   *
>   *  Setting KASLR_CHECK will trigger a search for "module_load_offset"
> - *  or "kaslr_regions" during the initial symbol sort operation, and
> + *  or "kaslr_get_random_long" during the initial symbol sort operation,
> and
>   *  if found, will set (RELOC_AUTO|KASLR).  On live systems, the search
>   *  is done here by checking /proc/kallsyms.
>   */
> @@ -646,7 +646,7 @@ kaslr_init(void)
>                 st->_stext_vmlinux = UNINITIALIZED;
>
>         if (ACTIVE() &&   /* Linux 3.15 */
> -           ((symbol_value_from_proc_kallsyms("kaslr_regions") != BADVAL)
> ||
> +           ((symbol_value_from_proc_kallsyms("kaslr_get_random_long") !=
> BADVAL) ||
>             (symbol_value_from_proc_kallsyms("module_load_offset") !=
> BADVAL))) {
>                 kt->flags2 |= (RELOC_AUTO|KASLR);
>                 st->_stext_vmlinux = UNINITIALIZED;
> @@ -14253,8 +14253,8 @@ numeric_forward(const void *P_x, const void *P_y)
>                         st->_stext_vmlinux = valueof(y);
>         }
>         if (kt->flags2 & KASLR_CHECK) {
> -               if (STREQ(x->name, "kaslr_regions") ||
> -                   STREQ(y->name, "kaslr_regions") ||
> +               if (STREQ(x->name, "kaslr_get_random_long") ||
> +                   STREQ(y->name, "kaslr_get_random_long") ||
>                     STREQ(x->name, "module_load_offset") ||
>                     STREQ(y->name, "module_load_offset")) {
>                         kt->flags2 &= ~KASLR_CHECK;
> --
> 2.46.1
>
--
Crash-utility mailing list -- devel@lists.crash-utility.osci.io
To unsubscribe send an email to devel-le...@lists.crash-utility.osci.io
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines: https://github.com/crash-utility/crash/wiki

Reply via email to