s390/kasan: reipl and kexec support
authorVasily Gorbik <gor@linux.ibm.com>
Mon, 20 Nov 2017 11:15:10 +0000 (12:15 +0100)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 9 Oct 2018 09:21:27 +0000 (11:21 +0200)
Some functions from both arch/s390/kernel/ipl.c and
arch/s390/kernel/machine_kexec.c are called without DAT enabled
(or with and without DAT enabled code paths). There is no easy way
to partially disable kasan for those files without a substantial
rework. Disable kasan for both files for now.

To avoid disabling kasan for arch/s390/kernel/diag.c DAT flag is
enabled in diag308 call. pcpu_delegate which disables DAT is marked
with __no_sanitize_address to disable instrumentation for that one
function.

Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/include/asm/processor.h
arch/s390/kernel/Makefile
arch/s390/kernel/ipl.c
arch/s390/kernel/smp.c

index 55956c96558cd422d80c4a89ab5ecc170328c1ab..34768e6ef4fb7c963b5d3f397d6a7535115eb8eb 100644 (file)
@@ -242,7 +242,7 @@ static inline unsigned long current_stack_pointer(void)
        return sp;
 }
 
-static inline unsigned short stap(void)
+static __no_sanitize_address_or_inline unsigned short stap(void)
 {
        unsigned short cpu_address;
 
index 1f9c98f7d9e24175a6a024c826e786d04d0dad55..386b1abb217bca267a6be64dacdf378ffeb0acbc 100644 (file)
@@ -24,6 +24,8 @@ UBSAN_SANITIZE_early.o                := n
 UBSAN_SANITIZE_early_nobss.o   := n
 
 KASAN_SANITIZE_early_nobss.o   := n
+KASAN_SANITIZE_ipl.o           := n
+KASAN_SANITIZE_machine_kexec.o := n
 
 #
 # Passing null pointers is ok for smp code, since we access the lowcore here.
index f1d69f78bb1decdfadd77854cf70f4f146863f4d..18a5d6317accd69f2e0c594bfeceed7433fb31ef 100644 (file)
@@ -156,6 +156,8 @@ static inline int __diag308(unsigned long subcode, void *addr)
 
 int diag308(unsigned long subcode, void *addr)
 {
+       if (IS_ENABLED(CONFIG_KASAN))
+               __arch_local_irq_stosm(0x04); /* enable DAT */
        diag_stat_inc(DIAG_STAT_X308);
        return __diag308(subcode, addr);
 }
index c98059faee460079688ff957a1c9eb2b2d90966a..1b3188f57b58f6dc1995f3cb9ae1134506450d27 100644 (file)
@@ -313,8 +313,9 @@ static void __pcpu_delegate(void (*func)(void*), void *data)
        func(data);     /* should not return */
 }
 
-static void pcpu_delegate(struct pcpu *pcpu, void (*func)(void *),
-                         void *data, unsigned long stack)
+static void __no_sanitize_address pcpu_delegate(struct pcpu *pcpu,
+                                               void (*func)(void *),
+                                               void *data, unsigned long stack)
 {
        struct lowcore *lc = lowcore_ptr[pcpu - pcpu_devices];
        unsigned long source_cpu = stap();