powerpc: don't use direct assignation during early boot.
authorChristophe Leroy <christophe.leroy@c-s.fr>
Fri, 26 Apr 2019 16:23:29 +0000 (16:23 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 2 May 2019 15:20:25 +0000 (01:20 +1000)
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>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/cputable.c
arch/powerpc/kernel/prom_init.c

index 1eab54bc6ee9385c8de90ac0b9cde6b7d6da1302..cd12f362b61ffa1aef884646661cf7aec95e43bb 100644 (file)
@@ -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
index 7017156168e8a5025cee60b760599fc56ed3c20b..d3b0d543d92436af351c581b88c4049386c0a519 100644 (file)
@@ -1264,8 +1264,14 @@ static void __init prom_check_platform_support(void)
        int prop_len = prom_getproplen(prom.chosen,
                                       "ibm,arch-vec-5-platform-support");
 
-       /* First copy the architecture vec template */
-       ibm_architecture_vec = ibm_architecture_vec_template;
+       /*
+        * First copy the architecture vec template
+        *
+        * use memcpy() instead of *vec = *vec_template so that GCC replaces it
+        * by __memcpy() when KASAN is active
+        */
+       memcpy(&ibm_architecture_vec, &ibm_architecture_vec_template,
+              sizeof(ibm_architecture_vec));
 
        if (prop_len > 1) {
                int i;