All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	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: [PATCH v10 06/18] powerpc/mm: don't use direct assignation during early boot.
Date: Tue, 12 Mar 2019 22:16:11 +0000 (UTC)	[thread overview]
Message-ID: <f025c7da8723e5392843e06a5bf00a447db014c2.1552428161.git.christophe.leroy@c-s.fr> (raw)
In-Reply-To: <cover.1552428161.git.christophe.leroy@c-s.fr>

In kernel/cputable.c, explicitly use memcpy() instead of *y = *x;
This will allow GCC to replace it with __memcpy() when KASAN is
selected.

Acked-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/kernel/cputable.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 1eab54bc6ee9..cd12f362b61f 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -2147,7 +2147,11 @@ void __init set_cur_cpu_spec(struct cpu_spec *s)
 	struct cpu_spec *t = &the_cpu_spec;
 
 	t = PTRRELOC(t);
-	*t = *s;
+	/*
+	 * use memcpy() instead of *t = *s so that GCC replaces it
+	 * by __memcpy() when KASAN is active
+	 */
+	memcpy(t, s, sizeof(*t));
 
 	*PTRRELOC(&cur_cpu_spec) = &the_cpu_spec;
 }
@@ -2161,8 +2165,11 @@ static struct cpu_spec * __init setup_cpu_spec(unsigned long offset,
 	t = PTRRELOC(t);
 	old = *t;
 
-	/* Copy everything, then do fixups */
-	*t = *s;
+	/*
+	 * Copy everything, then do fixups. Use memcpy() instead of *t = *s
+	 * so that GCC replaces it by __memcpy() when KASAN is active
+	 */
+	memcpy(t, s, sizeof(*t));
 
 	/*
 	 * If we are overriding a previous value derived from the real
-- 
2.13.3


WARNING: multiple messages have this Message-ID (diff)
From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	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-mm@kvack.org, linuxppc-dev@lists.ozlabs.org,
	linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com
Subject: [PATCH v10 06/18] powerpc/mm: don't use direct assignation during early boot.
Date: Tue, 12 Mar 2019 22:16:11 +0000 (UTC)	[thread overview]
Message-ID: <f025c7da8723e5392843e06a5bf00a447db014c2.1552428161.git.christophe.leroy@c-s.fr> (raw)
In-Reply-To: <cover.1552428161.git.christophe.leroy@c-s.fr>

In kernel/cputable.c, explicitly use memcpy() instead of *y = *x;
This will allow GCC to replace it with __memcpy() when KASAN is
selected.

Acked-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/kernel/cputable.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 1eab54bc6ee9..cd12f362b61f 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -2147,7 +2147,11 @@ void __init set_cur_cpu_spec(struct cpu_spec *s)
 	struct cpu_spec *t = &the_cpu_spec;
 
 	t = PTRRELOC(t);
-	*t = *s;
+	/*
+	 * use memcpy() instead of *t = *s so that GCC replaces it
+	 * by __memcpy() when KASAN is active
+	 */
+	memcpy(t, s, sizeof(*t));
 
 	*PTRRELOC(&cur_cpu_spec) = &the_cpu_spec;
 }
@@ -2161,8 +2165,11 @@ static struct cpu_spec * __init setup_cpu_spec(unsigned long offset,
 	t = PTRRELOC(t);
 	old = *t;
 
-	/* Copy everything, then do fixups */
-	*t = *s;
+	/*
+	 * Copy everything, then do fixups. Use memcpy() instead of *t = *s
+	 * so that GCC replaces it by __memcpy() when KASAN is active
+	 */
+	memcpy(t, s, sizeof(*t));
 
 	/*
 	 * If we are overriding a previous value derived from the real
-- 
2.13.3


  parent reply	other threads:[~2019-03-12 22:16 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-12 22:16 [PATCH v10 00/18] KASAN for powerpc/32 and RFC for 64bit Book3E Christophe Leroy
2019-03-12 22:16 ` Christophe Leroy
2019-03-12 22:16 ` [PATCH v10 01/18] powerpc/6xx: fix setup and use of SPRN_SPRG_PGDIR for hash32 Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH v10 02/18] powerpc/32: Move early_init() in a separate file Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH v10 03/18] powerpc: prepare string/mem functions for KASAN Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH v10 04/18] powerpc: remove CONFIG_CMDLINE #ifdef mess Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH v10 05/18] powerpc/prom_init: don't use string functions from lib/ Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 23:38   ` Daniel Axtens
2019-03-12 23:38     ` Daniel Axtens
2019-04-26 16:24     ` Christophe Leroy
2019-04-26 16:24       ` Christophe Leroy
2019-03-12 22:16 ` Christophe Leroy [this message]
2019-03-12 22:16   ` [PATCH v10 06/18] powerpc/mm: don't use direct assignation during early boot Christophe Leroy
2019-03-12 22:16 ` [PATCH v10 07/18] powerpc/32: use memset() instead of memset_io() to zero BSS Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH v10 08/18] powerpc/32: make KVIRT_TOP dependent on FIXMAP_START Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH v10 09/18] powerpc/32: prepare shadow area for KASAN Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH v10 10/18] powerpc: disable KASAN instrumentation on early/critical files Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH v10 11/18] powerpc/32: Add KASAN support Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH v10 12/18] powerpc/32s: move hash code patching out of MMU_init_hw() Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH v10 13/18] powerpc/32s: set up an early static hash table for KASAN Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH v10 14/18] powerpc/32s: map kasan zero shadow with PAGE_READONLY instead of PAGE_KERNEL_RO Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH RFC v3 15/18] kasan: do not open-code addr_has_shadow Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH RFC v3 16/18] kasan: allow architectures to manage the memory-to-shadow mapping Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH RFC v3 17/18] kasan: allow architectures to provide an outline readiness check Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-12 22:16 ` [PATCH RFC v3 18/18] powerpc: KASAN for 64bit Book3E Christophe Leroy
2019-03-12 22:16   ` Christophe Leroy
2019-03-13  7:02   ` Christophe Leroy
2019-03-13  8:30     ` Christophe Leroy

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=f025c7da8723e5392843e06a5bf00a447db014c2.1552428161.git.christophe.leroy@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.