From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Nicholas Piggin <npiggin@gmail.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
Andrey Ryabinin <aryabinin@virtuozzo.com>,
Alexander Potapenko <glider@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Daniel Axtens <dja@axtens.net>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
kasan-dev@googlegroups.com, linux-mm@kvack.org
Subject: Re: [PATCH v5 3/3] powerpc/32: Add KASAN support
Date: Tue, 19 Feb 2019 19:03:38 +0100 [thread overview]
Message-ID: <8654376c-2c55-89b0-cd79-0bcf02338519@c-s.fr> (raw)
In-Reply-To: <87a7itqwdo.fsf@concordia.ellerman.id.au>
Le 18/02/2019 à 10:27, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>
>> diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
>> index e0637730a8e7..dba2c1038363 100644
>> --- a/arch/powerpc/include/asm/ppc_asm.h
>> +++ b/arch/powerpc/include/asm/ppc_asm.h
>> @@ -251,6 +251,10 @@ GLUE(.,name):
>>
>> #define _GLOBAL_TOC(name) _GLOBAL(name)
>>
>> +#define KASAN_OVERRIDE(x, y) \
>> + .weak x; \
>> + .set x, y
>> +
>
> Can you add a comment describing what that does and why?
It's gone. Hope the new approach is more clear. It's now in a dedicated
patch.
>
>> diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
>> index 879b36602748..fc4c42262694 100644
>> --- a/arch/powerpc/kernel/Makefile
>> +++ b/arch/powerpc/kernel/Makefile
>> @@ -16,8 +16,9 @@ CFLAGS_prom_init.o += -fPIC
>> CFLAGS_btext.o += -fPIC
>> endif
>>
>> -CFLAGS_cputable.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
>> -CFLAGS_prom_init.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
>> +CFLAGS_early_32.o += -DDISABLE_BRANCH_PROFILING
>> +CFLAGS_cputable.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) -DDISABLE_BRANCH_PROFILING
>> +CFLAGS_prom_init.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) -DDISABLE_BRANCH_PROFILING
>
> Why do we need to disable branch profiling now?
Recommended by Andrey, see https://patchwork.ozlabs.org/patch/1023887/
Maybe it should be only when KASAN is active ? For prom_init it should
probably be all the time, for the others I don't know. Can't remember
why I did it that way.
>
> I'd probably be happier if all the CFLAGS changes were done in a leadup
> patch to make them more obvious.
Oops, I forgot to read your mail entirely before sending out v6. Indeed
I only read first part. Anyway, that's probably not the last run.
>
>> diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh
>> index 667df97d2595..da6bb16e0876 100644
>> --- a/arch/powerpc/kernel/prom_init_check.sh
>> +++ b/arch/powerpc/kernel/prom_init_check.sh
>> @@ -16,8 +16,16 @@
>> # If you really need to reference something from prom_init.o add
>> # it to the list below:
>>
>> +grep CONFIG_KASAN=y .config >/dev/null
>
> Just to be safe "^CONFIG_KASAN=y$" ?
ok
>
>> +if [ $? -eq 0 ]
>> +then
>> + MEMFCT="__memcpy __memset"
>> +else
>> + MEMFCT="memcpy memset"
>> +fi
>
> MEM_FUNCS ?
Yes, I change it now before I forget.
>
>> diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
>> index 3bf9fc6fd36c..ce8d4a9f810a 100644
>> --- a/arch/powerpc/lib/Makefile
>> +++ b/arch/powerpc/lib/Makefile
>> @@ -8,6 +8,14 @@ ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC)
>> CFLAGS_REMOVE_code-patching.o = $(CC_FLAGS_FTRACE)
>> CFLAGS_REMOVE_feature-fixups.o = $(CC_FLAGS_FTRACE)
>>
>> +KASAN_SANITIZE_code-patching.o := n
>> +KASAN_SANITIZE_feature-fixups.o := n
>> +
>> +ifdef CONFIG_KASAN
>> +CFLAGS_code-patching.o += -DDISABLE_BRANCH_PROFILING
>> +CFLAGS_feature-fixups.o += -DDISABLE_BRANCH_PROFILING
>> +endif
>
> There's that branch profiling again, though here it's only if KASAN is enabled.
>
>> diff --git a/arch/powerpc/mm/kasan_init.c b/arch/powerpc/mm/kasan_init.c
>> new file mode 100644
>> index 000000000000..bd8e0a263e12
>> --- /dev/null
>> +++ b/arch/powerpc/mm/kasan_init.c
>> @@ -0,0 +1,114 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +
>> +#define DISABLE_BRANCH_PROFILING
>> +
>> +#include <linux/kasan.h>
>> +#include <linux/printk.h>
>> +#include <linux/memblock.h>
>> +#include <linux/sched/task.h>
>> +#include <asm/pgalloc.h>
>> +
>> +void __init kasan_early_init(void)
>> +{
>> + unsigned long addr = KASAN_SHADOW_START;
>> + unsigned long end = KASAN_SHADOW_END;
>> + unsigned long next;
>> + pmd_t *pmd = pmd_offset(pud_offset(pgd_offset_k(addr), addr), addr);
>
> Can none of those fail?
map_kernel_page() in pgtable_32.c does exactly the same.
pud_offset() and pmd_offset() are no-ops and only serve as type
modifiers, so pmd will get the value returned by pgd_offset_k() which
should always be valid unless init_mm->pgd is bad.
Christophe
>
>
> cheers
>
prev parent reply other threads:[~2019-02-19 18:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-12 13:36 [PATCH v5 0/3] KASAN for powerpc/32 Christophe Leroy
2019-02-12 13:36 ` [PATCH v5 1/3] powerpc/mm: prepare kernel for KAsan on PPC32 Christophe Leroy
2019-02-12 13:36 ` [PATCH v5 2/3] powerpc/32: Move early_init() in a separate file Christophe Leroy
2019-02-12 13:36 ` [PATCH v5 3/3] powerpc/32: Add KASAN support Christophe Leroy
2019-02-14 22:04 ` Daniel Axtens
2019-02-15 8:41 ` Christophe Leroy
2019-02-15 10:01 ` Andrey Ryabinin
2019-02-15 10:10 ` Christophe Leroy
2019-02-15 10:38 ` Andrey Ryabinin
2019-02-18 9:27 ` Michael Ellerman
2019-02-19 18:03 ` Christophe Leroy [this message]
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=8654376c-2c55-89b0-cd79-0bcf02338519@c-s.fr \
--to=christophe.leroy@c-s.fr \
--cc=aneesh.kumar@linux.ibm.com \
--cc=aryabinin@virtuozzo.com \
--cc=benh@kernel.crashing.org \
--cc=dja@axtens.net \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=paulus@samba.org \
/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