]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
powerpc/64: Use barrier_nospec in syscall entry
authorMichael Ellerman <mpe@ellerman.id.au>
Thu, 11 Apr 2019 11:46:03 +0000 (21:46 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Apr 2019 06:36:40 +0000 (08:36 +0200)
commit 51973a815c6b46d7b23b68d6af371ad1c9d503ca upstream.

Our syscall entry is done in assembly so patch in an explicit
barrier_nospec.

Based on a patch by Michal Suchanek.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/kernel/entry_64.S

index e24ae0fa80ed9b844aa7d3f7a967314b446a7e5c..11e39066238402ffef41b6daf0f6b9dd2090a985 100644 (file)
@@ -38,6 +38,7 @@
 #include <asm/context_tracking.h>
 #include <asm/tm.h>
 #include <asm/ppc-opcode.h>
+#include <asm/barrier.h>
 #include <asm/export.h>
 #ifdef CONFIG_PPC_BOOK3S
 #include <asm/exception-64s.h>
@@ -180,6 +181,15 @@ system_call:                       /* label this so stack traces look sane */
        clrldi  r8,r8,32
 15:
        slwi    r0,r0,4
+
+       barrier_nospec_asm
+       /*
+        * Prevent the load of the handler below (based on the user-passed
+        * system call number) being speculatively executed until the test
+        * against NR_syscalls and branch to .Lsyscall_enosys above has
+        * committed.
+        */
+
        ldx     r12,r11,r0      /* Fetch system call handler [ptr] */
        mtctr   r12
        bctrl                   /* Call handler */