syscalls/x86: Use the correct function type in SYSCALL_DEFINE0
authorSami Tolvanen <samitolvanen@google.com>
Tue, 8 Oct 2019 22:40:45 +0000 (15:40 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 31 Dec 2019 15:44:03 +0000 (16:44 +0100)
[ Upstream commit 8661d769ab77c675b5eb6c3351a372b9fbc1bf40 ]

Although a syscall defined using SYSCALL_DEFINE0 doesn't accept
parameters, use the correct function type to avoid type mismatches
with Control-Flow Integrity (CFI) checking.

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Acked-by: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H . Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20191008224049.115427-2-samitolvanen@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/include/asm/syscall_wrapper.h

index e046a40..90eb70d 100644 (file)
  * To keep the naming coherent, re-define SYSCALL_DEFINE0 to create an alias
  * named __ia32_sys_*()
  */
-#define SYSCALL_DEFINE0(sname)                                 \
-       SYSCALL_METADATA(_##sname, 0);                          \
-       asmlinkage long __x64_sys_##sname(void);                \
-       ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO);        \
-       SYSCALL_ALIAS(__ia32_sys_##sname, __x64_sys_##sname);   \
-       asmlinkage long __x64_sys_##sname(void)
+
+#define SYSCALL_DEFINE0(sname)                                         \
+       SYSCALL_METADATA(_##sname, 0);                                  \
+       asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused);\
+       ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO);                \
+       SYSCALL_ALIAS(__ia32_sys_##sname, __x64_sys_##sname);           \
+       asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused)
 
 #define COND_SYSCALL(name)                                             \
        cond_syscall(__x64_sys_##name);                                 \
  * macros to work correctly.
  */
 #ifndef SYSCALL_DEFINE0
-#define SYSCALL_DEFINE0(sname)                                 \
-       SYSCALL_METADATA(_##sname, 0);                          \
-       asmlinkage long __x64_sys_##sname(void);                \
-       ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO);        \
-       asmlinkage long __x64_sys_##sname(void)
+#define SYSCALL_DEFINE0(sname)                                         \
+       SYSCALL_METADATA(_##sname, 0);                                  \
+       asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused);\
+       ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO);                \
+       asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused)
 #endif
 
 #ifndef COND_SYSCALL