linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Huacai Chen <chenhuacai@kernel.org>
To: Qing Zhang <zhangqing@loongson.cn>
Cc: Xi Ruoyao <xry111@xry111.site>,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>,
	 Jonathan Corbet <corbet@lwn.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	 Alexander Potapenko <glider@google.com>,
	Andrey Konovalov <andreyknvl@gmail.com>,
	 Dmitry Vyukov <dvyukov@google.com>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	 WANG Xuerui <kernel@xen0n.name>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	kasan-dev@googlegroups.com,  linux-doc@vger.kernel.org,
	linux-mm@kvack.org, loongarch@lists.linux.dev,
	 linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] LoongArch: Add kernel address sanitizer support
Date: Wed, 29 Mar 2023 08:22:37 +0800	[thread overview]
Message-ID: <CAAhV-H5APsBxC8nNa81t3HXum1EU1hOj4S6UC7xLHD7_BCJd7g@mail.gmail.com> (raw)
In-Reply-To: <1c231587-3b70-22ab-d554-ebe3de407909@loongson.cn>

On Tue, Mar 28, 2023 at 8:15 PM Qing Zhang <zhangqing@loongson.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;
> >
>


  reply	other threads:[~2023-03-29  0:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28 11:17 Qing Zhang
2023-03-28 11:39 ` Xi Ruoyao
2023-03-28 12:15   ` Qing Zhang
2023-03-29  0:22     ` Huacai Chen [this message]
2023-03-29  2:01       ` Qing Zhang
2023-03-28 11:57 ` Youling Tang
2023-03-28 12:08 ` Youling Tang
2023-03-28 12:27   ` Qing Zhang
2023-03-29 19:02 ` Andrey Konovalov
2023-03-30  2:06   ` Qing Zhang
2023-03-30  2:55     ` Andrey Konovalov
2023-03-30  4:32       ` Qing Zhang
2023-03-31 15:58         ` Andrey Konovalov
2023-04-01  3:23           ` Qing Zhang
2023-03-30  6:50 ` Youling Tang
2023-03-30  8:53   ` Qing Zhang
2023-03-31  8:07 ` Youling Tang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAhV-H5APsBxC8nNa81t3HXum1EU1hOj4S6UC7xLHD7_BCJd7g@mail.gmail.com \
    --to=chenhuacai@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=corbet@lwn.net \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=kernel@xen0n.name \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=loongarch@lists.linux.dev \
    --cc=ryabinin.a.a@gmail.com \
    --cc=vincenzo.frascino@arm.com \
    --cc=xry111@xry111.site \
    --cc=zhangqing@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox