lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 29 Mar 2023 08:22:37 +0800
From:   Huacai Chen <chenhuacai@...nel.org>
To:     Qing Zhang <zhangqing@...ngson.cn>
Cc:     Xi Ruoyao <xry111@...111.site>,
        Andrey Ryabinin <ryabinin.a.a@...il.com>,
        Jonathan Corbet <corbet@....net>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Alexander Potapenko <glider@...gle.com>,
        Andrey Konovalov <andreyknvl@...il.com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        Vincenzo Frascino <vincenzo.frascino@....com>,
        WANG Xuerui <kernel@...0n.name>,
        Jiaxun Yang <jiaxun.yang@...goat.com>,
        kasan-dev@...glegroups.com, linux-doc@...r.kernel.org,
        linux-mm@...ck.org, loongarch@...ts.linux.dev,
        linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH] LoongArch: Add kernel address sanitizer support

On Tue, Mar 28, 2023 at 8:15 PM Qing Zhang <zhangqing@...ngson.cn> wrote:
>
> Hi, Ruoyao
>
> On 2023/3/28 下午7:39, Xi Ruoyao wrote:
> > On Tue, 2023-03-28 at 19:17 +0800, Qing Zhang wrote:
> >
> > /* snip */
> >
> >
> >> -void * __init relocate_kernel(void)
> >> +unsigned long __init relocate_kernel(void)
> >
> > Why we must modify relocate_kernel for KASAN?
>
> When the CONFIG_RANDOMIZE_BASE is enabled, the kernel will be updated to
> a random new address.
> Kasan needs to call kasan_early_init before start_kernel.
> There are two situations:
> 1> After enabling CONFIG_RELOCATABLE, call kasan_early_init.
> 2> After CONFIG_RELOCATABLE is not enabled, call kasan_early_init.
>
> In order to prevent code redundancy and semantic problems caused by
> calling kasan_early_init (before jr a0) at the old PC.
In my opinion, you can call kasan_early_init before relocate_kernel in
head.S, then no redundancy.

Huacai
>
> Thanks,
> -Qing
> >
> >>   {
> >>          unsigned long kernel_length;
> >>          unsigned long random_offset = 0;
> >>          void *location_new = _text; /* Default to original kernel start */
> >> -       void *kernel_entry = start_kernel; /* Default to original kernel entry point */
> >>          char *cmdline = early_ioremap(fw_arg1, COMMAND_LINE_SIZE); /* Boot command line is passed in fw_arg1 */
> >>
> >>          strscpy(boot_command_line, cmdline, COMMAND_LINE_SIZE);
> >> @@ -190,9 +189,6 @@ void * __init relocate_kernel(void)
> >>
> >>                  reloc_offset += random_offset;
> >>
> >> -               /* Return the new kernel's entry point */
> >> -               kernel_entry = RELOCATED_KASLR(start_kernel);
> >> -
> >>                  /* The current thread is now within the relocated kernel */
> >>                  __current_thread_info = RELOCATED_KASLR(__current_thread_info);
> >>
> >> @@ -204,7 +200,7 @@ void * __init relocate_kernel(void)
> >>
> >>          relocate_absolute(random_offset);
> >>
> >> -       return kernel_entry;
> >> +       return random_offset;
> >
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ