linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: hailong  <hailongliiu@yeah.net>
To: "Linus Walleij" <linus.walleij@linaro.org>
Cc: "Andrey Ryabinin" <aryabinin@virtuozzo.com>,
	 "Ziliang Guo" <guo.ziliang@zte.com.cn>,
	 "Hailong Liu" <liu.hailong6@zte.com.cn>,
	 "Russell King" <linux@armlinux.org.uk>,
	 kasan-dev <kasan-dev@googlegroups.com>,
	 "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	 "Linux Memory Management List" <linux-mm@kvack.org>,
	 "Alexander Potapenko" <glider@google.com>,
	 "Dmitry Vyukov" <dvyukov@google.com>,
	 "Andrew Morton" <akpm@linux-foundation.org>,
	 "Linux ARM" <linux-arm-kernel@lists.infradead.org>
Subject: Re:Re: [PATCH] arm/kasan:fix the arry size of kasan_early_shadow_pte
Date: Sun, 10 Jan 2021 18:20:16 +0800 (CST)	[thread overview]
Message-ID: <4c009d78.4e1.176ebcf8bc9.Coremail.hailongliiu@yeah.net> (raw)
In-Reply-To: <CACRpkdb73diprma9Z1-4nm5A9OTQMeGVK=Hcqiwny9VOVdA=QQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1886 bytes --]


At 2021-01-10 05:26:08, "Linus Walleij" <linus.walleij@linaro.org> wrote:
>On Sat, Jan 9, 2021 at 5:51 AM Hailong liu <hailongliiu@yeah.net> wrote:
>
>> From: Hailong Liu <liu.hailong6@zte.com.cn>
>>
>> The size of kasan_early_shadow_pte[] now is PTRS_PER_PTE which defined to
>> 512 for arm architecture. This means that it only covers the prev Linux pte
>> entries, but not the HWTABLE pte entries for arm.
>>
>> The reason it works well current is that the symbol kasan_early_shadow_page
>> immediately following kasan_early_shadow_pte in memory is page aligned,
>> which makes kasan_early_shadow_pte look like a 4KB size array. But we can't
>> ensure the order always right with different compiler/linker, nor more bss
>> symbols be introduced.
>>
>> We had a test with QEMU + vexpress:put a 512KB-size symbol with attribute
>> __section(".bss..page_aligned") after kasan_early_shadow_pte, and poison it
>> after kasan_early_init(). Then enabled CONFIG_KASAN, it failed to boot up.
>>
>> Signed-off-by: Hailong Liu <liu.hailong6@zte.com.cn>
>> Signed-off-by: Ziliang Guo <guo.ziliang@zte.com.cn>
>
>OK I see the problem, I think.
>
>> +#ifndef PTE_HWTABLE_PTRS
>> +#define PTE_HWTABLE_PTRS 0
>> +#endif
>
>Can this even happen? We have either pgtable-2level.h or
>pgtable-3level.h, both of which define PTE_HWTABLE_PTRS.
>

I guess not for arm. But I'm not sure for other ARCHs.

>>  extern unsigned char kasan_early_shadow_page[PAGE_SIZE];
>> -extern pte_t kasan_early_shadow_pte[PTRS_PER_PTE];
>> +extern pte_t kasan_early_shadow_pte[PTRS_PER_PTE + PTE_HWTABLE_PTRS];
>
>Yeah this looks exactly like bm_pte so it makes sense.
>

Yes, it comes from prototype of pm_pte. And it does solve the
problems our project encountered and seems to work well for now.

>If you drop the first ifndef,
>Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>
>Yours,
>Linus Walleij

Thanks.

[-- Attachment #2: Type: text/html, Size: 2278 bytes --]

  reply	other threads:[~2021-01-10 10:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-09  4:46 Hailong liu
2021-01-09  8:51 ` Ard Biesheuvel
2021-01-09 21:26 ` Linus Walleij
2021-01-10 10:20   ` hailong [this message]
2021-01-10 12:03     ` Linus Walleij
2021-01-12  6:18       ` Andrew Morton
2021-01-12  9:05         ` Ard Biesheuvel

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=4c009d78.4e1.176ebcf8bc9.Coremail.hailongliiu@yeah.net \
    --to=hailongliiu@yeah.net \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=guo.ziliang@zte.com.cn \
    --cc=kasan-dev@googlegroups.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@armlinux.org.uk \
    --cc=liu.hailong6@zte.com.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