Commit cd4771f7 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'x86-entry-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 syscall entry updates from Ingo Molnar:
 "These changes relate to the preparatory cleanup of syscall function
  type signatures - to fix indirect call mismatches with Control-Flow
  Integrity (CFI) checking.

  No change in behavior intended"

* 'x86-entry-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/mm: Use the correct function type for native_set_fixmap()
  syscalls/x86: Fix function types in COND_SYSCALL
  syscalls/x86: Use the correct function type for sys_ni_syscall
  syscalls/x86: Use COMPAT_SYSCALL_DEFINE0 for IA32 (rt_)sigreturn
  syscalls/x86: Wire up COMPAT_SYSCALL_DEFINE0
  syscalls/x86: Use the correct function type in SYSCALL_DEFINE0
parents a25bbc26 f53e2cd0
...@@ -10,13 +10,11 @@ ...@@ -10,13 +10,11 @@
#ifdef CONFIG_IA32_EMULATION #ifdef CONFIG_IA32_EMULATION
/* On X86_64, we use struct pt_regs * to pass parameters to syscalls */ /* On X86_64, we use struct pt_regs * to pass parameters to syscalls */
#define __SYSCALL_I386(nr, sym, qual) extern asmlinkage long sym(const struct pt_regs *); #define __SYSCALL_I386(nr, sym, qual) extern asmlinkage long sym(const struct pt_regs *);
#define __sys_ni_syscall __ia32_sys_ni_syscall
/* this is a lie, but it does not hurt as sys_ni_syscall just returns -EINVAL */
extern asmlinkage long sys_ni_syscall(const struct pt_regs *);
#else /* CONFIG_IA32_EMULATION */ #else /* CONFIG_IA32_EMULATION */
#define __SYSCALL_I386(nr, sym, qual) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); #define __SYSCALL_I386(nr, sym, qual) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
extern asmlinkage long sys_ni_syscall(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); extern asmlinkage long sys_ni_syscall(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
#define __sys_ni_syscall sys_ni_syscall
#endif /* CONFIG_IA32_EMULATION */ #endif /* CONFIG_IA32_EMULATION */
#include <asm/syscalls_32.h> #include <asm/syscalls_32.h>
...@@ -29,6 +27,6 @@ __visible const sys_call_ptr_t ia32_sys_call_table[__NR_syscall_compat_max+1] = ...@@ -29,6 +27,6 @@ __visible const sys_call_ptr_t ia32_sys_call_table[__NR_syscall_compat_max+1] =
* Smells like a compiler bug -- it doesn't work * Smells like a compiler bug -- it doesn't work
* when the & below is removed. * when the & below is removed.
*/ */
[0 ... __NR_syscall_compat_max] = &sys_ni_syscall, [0 ... __NR_syscall_compat_max] = &__sys_ni_syscall,
#include <asm/syscalls_32.h> #include <asm/syscalls_32.h>
}; };
...@@ -4,11 +4,17 @@ ...@@ -4,11 +4,17 @@
#include <linux/linkage.h> #include <linux/linkage.h>
#include <linux/sys.h> #include <linux/sys.h>
#include <linux/cache.h> #include <linux/cache.h>
#include <linux/syscalls.h>
#include <asm/asm-offsets.h> #include <asm/asm-offsets.h>
#include <asm/syscall.h> #include <asm/syscall.h>
/* this is a lie, but it does not hurt as sys_ni_syscall just returns -EINVAL */ extern asmlinkage long sys_ni_syscall(void);
extern asmlinkage long sys_ni_syscall(const struct pt_regs *);
SYSCALL_DEFINE0(ni_syscall)
{
return sys_ni_syscall();
}
#define __SYSCALL_64(nr, sym, qual) extern asmlinkage long sym(const struct pt_regs *); #define __SYSCALL_64(nr, sym, qual) extern asmlinkage long sym(const struct pt_regs *);
#define __SYSCALL_X32(nr, sym, qual) __SYSCALL_64(nr, sym, qual) #define __SYSCALL_X32(nr, sym, qual) __SYSCALL_64(nr, sym, qual)
#include <asm/syscalls_64.h> #include <asm/syscalls_64.h>
...@@ -23,7 +29,7 @@ asmlinkage const sys_call_ptr_t sys_call_table[__NR_syscall_max+1] = { ...@@ -23,7 +29,7 @@ asmlinkage const sys_call_ptr_t sys_call_table[__NR_syscall_max+1] = {
* Smells like a compiler bug -- it doesn't work * Smells like a compiler bug -- it doesn't work
* when the & below is removed. * when the & below is removed.
*/ */
[0 ... __NR_syscall_max] = &sys_ni_syscall, [0 ... __NR_syscall_max] = &__x64_sys_ni_syscall,
#include <asm/syscalls_64.h> #include <asm/syscalls_64.h>
}; };
...@@ -40,7 +46,7 @@ asmlinkage const sys_call_ptr_t x32_sys_call_table[__NR_syscall_x32_max+1] = { ...@@ -40,7 +46,7 @@ asmlinkage const sys_call_ptr_t x32_sys_call_table[__NR_syscall_x32_max+1] = {
* Smells like a compiler bug -- it doesn't work * Smells like a compiler bug -- it doesn't work
* when the & below is removed. * when the & below is removed.
*/ */
[0 ... __NR_syscall_x32_max] = &sys_ni_syscall, [0 ... __NR_syscall_x32_max] = &__x64_sys_ni_syscall,
#include <asm/syscalls_64.h> #include <asm/syscalls_64.h>
}; };
......
...@@ -124,13 +124,13 @@ ...@@ -124,13 +124,13 @@
110 i386 iopl sys_iopl __ia32_sys_iopl 110 i386 iopl sys_iopl __ia32_sys_iopl
111 i386 vhangup sys_vhangup __ia32_sys_vhangup 111 i386 vhangup sys_vhangup __ia32_sys_vhangup
112 i386 idle 112 i386 idle
113 i386 vm86old sys_vm86old sys_ni_syscall 113 i386 vm86old sys_vm86old __ia32_sys_ni_syscall
114 i386 wait4 sys_wait4 __ia32_compat_sys_wait4 114 i386 wait4 sys_wait4 __ia32_compat_sys_wait4
115 i386 swapoff sys_swapoff __ia32_sys_swapoff 115 i386 swapoff sys_swapoff __ia32_sys_swapoff
116 i386 sysinfo sys_sysinfo __ia32_compat_sys_sysinfo 116 i386 sysinfo sys_sysinfo __ia32_compat_sys_sysinfo
117 i386 ipc sys_ipc __ia32_compat_sys_ipc 117 i386 ipc sys_ipc __ia32_compat_sys_ipc
118 i386 fsync sys_fsync __ia32_sys_fsync 118 i386 fsync sys_fsync __ia32_sys_fsync
119 i386 sigreturn sys_sigreturn sys32_sigreturn 119 i386 sigreturn sys_sigreturn __ia32_compat_sys_sigreturn
120 i386 clone sys_clone __ia32_compat_sys_x86_clone 120 i386 clone sys_clone __ia32_compat_sys_x86_clone
121 i386 setdomainname sys_setdomainname __ia32_sys_setdomainname 121 i386 setdomainname sys_setdomainname __ia32_sys_setdomainname
122 i386 uname sys_newuname __ia32_sys_newuname 122 i386 uname sys_newuname __ia32_sys_newuname
...@@ -177,14 +177,14 @@ ...@@ -177,14 +177,14 @@
163 i386 mremap sys_mremap __ia32_sys_mremap 163 i386 mremap sys_mremap __ia32_sys_mremap
164 i386 setresuid sys_setresuid16 __ia32_sys_setresuid16 164 i386 setresuid sys_setresuid16 __ia32_sys_setresuid16
165 i386 getresuid sys_getresuid16 __ia32_sys_getresuid16 165 i386 getresuid sys_getresuid16 __ia32_sys_getresuid16
166 i386 vm86 sys_vm86 sys_ni_syscall 166 i386 vm86 sys_vm86 __ia32_sys_ni_syscall
167 i386 query_module 167 i386 query_module
168 i386 poll sys_poll __ia32_sys_poll 168 i386 poll sys_poll __ia32_sys_poll
169 i386 nfsservctl 169 i386 nfsservctl
170 i386 setresgid sys_setresgid16 __ia32_sys_setresgid16 170 i386 setresgid sys_setresgid16 __ia32_sys_setresgid16
171 i386 getresgid sys_getresgid16 __ia32_sys_getresgid16 171 i386 getresgid sys_getresgid16 __ia32_sys_getresgid16
172 i386 prctl sys_prctl __ia32_sys_prctl 172 i386 prctl sys_prctl __ia32_sys_prctl
173 i386 rt_sigreturn sys_rt_sigreturn sys32_rt_sigreturn 173 i386 rt_sigreturn sys_rt_sigreturn __ia32_compat_sys_rt_sigreturn
174 i386 rt_sigaction sys_rt_sigaction __ia32_compat_sys_rt_sigaction 174 i386 rt_sigaction sys_rt_sigaction __ia32_compat_sys_rt_sigaction
175 i386 rt_sigprocmask sys_rt_sigprocmask __ia32_compat_sys_rt_sigprocmask 175 i386 rt_sigprocmask sys_rt_sigprocmask __ia32_compat_sys_rt_sigprocmask
176 i386 rt_sigpending sys_rt_sigpending __ia32_compat_sys_rt_sigpending 176 i386 rt_sigpending sys_rt_sigpending __ia32_compat_sys_rt_sigpending
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/personality.h> #include <linux/personality.h>
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/binfmts.h> #include <linux/binfmts.h>
#include <linux/syscalls.h>
#include <asm/ucontext.h> #include <asm/ucontext.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <asm/fpu/internal.h> #include <asm/fpu/internal.h>
...@@ -118,7 +119,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs, ...@@ -118,7 +119,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
return err; return err;
} }
asmlinkage long sys32_sigreturn(void) COMPAT_SYSCALL_DEFINE0(sigreturn)
{ {
struct pt_regs *regs = current_pt_regs(); struct pt_regs *regs = current_pt_regs();
struct sigframe_ia32 __user *frame = (struct sigframe_ia32 __user *)(regs->sp-8); struct sigframe_ia32 __user *frame = (struct sigframe_ia32 __user *)(regs->sp-8);
...@@ -144,7 +145,7 @@ asmlinkage long sys32_sigreturn(void) ...@@ -144,7 +145,7 @@ asmlinkage long sys32_sigreturn(void)
return 0; return 0;
} }
asmlinkage long sys32_rt_sigreturn(void) COMPAT_SYSCALL_DEFINE0(rt_sigreturn)
{ {
struct pt_regs *regs = current_pt_regs(); struct pt_regs *regs = current_pt_regs();
struct rt_sigframe_ia32 __user *frame; struct rt_sigframe_ia32 __user *frame;
......
...@@ -156,7 +156,7 @@ extern pte_t *kmap_pte; ...@@ -156,7 +156,7 @@ extern pte_t *kmap_pte;
extern pte_t *pkmap_page_table; extern pte_t *pkmap_page_table;
void __native_set_fixmap(enum fixed_addresses idx, pte_t pte); void __native_set_fixmap(enum fixed_addresses idx, pte_t pte);
void native_set_fixmap(enum fixed_addresses idx, void native_set_fixmap(unsigned /* enum fixed_addresses */ idx,
phys_addr_t phys, pgprot_t flags); phys_addr_t phys, pgprot_t flags);
#ifndef CONFIG_PARAVIRT_XXL #ifndef CONFIG_PARAVIRT_XXL
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#ifndef _ASM_X86_SYSCALL_WRAPPER_H #ifndef _ASM_X86_SYSCALL_WRAPPER_H
#define _ASM_X86_SYSCALL_WRAPPER_H #define _ASM_X86_SYSCALL_WRAPPER_H
struct pt_regs;
/* Mapping of registers to parameters for syscalls on x86-64 and x32 */ /* Mapping of registers to parameters for syscalls on x86-64 and x32 */
#define SC_X86_64_REGS_TO_ARGS(x, ...) \ #define SC_X86_64_REGS_TO_ARGS(x, ...) \
__MAP(x,__SC_ARGS \ __MAP(x,__SC_ARGS \
...@@ -28,13 +30,21 @@ ...@@ -28,13 +30,21 @@
* kernel/sys_ni.c and SYS_NI in kernel/time/posix-stubs.c to cover this * kernel/sys_ni.c and SYS_NI in kernel/time/posix-stubs.c to cover this
* case as well. * case as well.
*/ */
#define __IA32_COMPAT_SYS_STUB0(x, name) \
asmlinkage long __ia32_compat_sys_##name(const struct pt_regs *regs);\
ALLOW_ERROR_INJECTION(__ia32_compat_sys_##name, ERRNO); \
asmlinkage long __ia32_compat_sys_##name(const struct pt_regs *regs)\
{ \
return __se_compat_sys_##name(); \
}
#define __IA32_COMPAT_SYS_STUBx(x, name, ...) \ #define __IA32_COMPAT_SYS_STUBx(x, name, ...) \
asmlinkage long __ia32_compat_sys##name(const struct pt_regs *regs);\ asmlinkage long __ia32_compat_sys##name(const struct pt_regs *regs);\
ALLOW_ERROR_INJECTION(__ia32_compat_sys##name, ERRNO); \ ALLOW_ERROR_INJECTION(__ia32_compat_sys##name, ERRNO); \
asmlinkage long __ia32_compat_sys##name(const struct pt_regs *regs)\ asmlinkage long __ia32_compat_sys##name(const struct pt_regs *regs)\
{ \ { \
return __se_compat_sys##name(SC_IA32_REGS_TO_ARGS(x,__VA_ARGS__));\ return __se_compat_sys##name(SC_IA32_REGS_TO_ARGS(x,__VA_ARGS__));\
} \ }
#define __IA32_SYS_STUBx(x, name, ...) \ #define __IA32_SYS_STUBx(x, name, ...) \
asmlinkage long __ia32_sys##name(const struct pt_regs *regs); \ asmlinkage long __ia32_sys##name(const struct pt_regs *regs); \
...@@ -48,16 +58,23 @@ ...@@ -48,16 +58,23 @@
* To keep the naming coherent, re-define SYSCALL_DEFINE0 to create an alias * To keep the naming coherent, re-define SYSCALL_DEFINE0 to create an alias
* named __ia32_sys_*() * named __ia32_sys_*()
*/ */
#define SYSCALL_DEFINE0(sname) \ #define SYSCALL_DEFINE0(sname) \
SYSCALL_METADATA(_##sname, 0); \ SYSCALL_METADATA(_##sname, 0); \
asmlinkage long __x64_sys_##sname(void); \ asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused);\
ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \ ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \
SYSCALL_ALIAS(__ia32_sys_##sname, __x64_sys_##sname); \ SYSCALL_ALIAS(__ia32_sys_##sname, __x64_sys_##sname); \
asmlinkage long __x64_sys_##sname(void) asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused)
#define COND_SYSCALL(name) \ #define COND_SYSCALL(name) \
cond_syscall(__x64_sys_##name); \ asmlinkage __weak long __x64_sys_##name(const struct pt_regs *__unused) \
cond_syscall(__ia32_sys_##name) { \
return sys_ni_syscall(); \
} \
asmlinkage __weak long __ia32_sys_##name(const struct pt_regs *__unused)\
{ \
return sys_ni_syscall(); \
}
#define SYS_NI(name) \ #define SYS_NI(name) \
SYSCALL_ALIAS(__x64_sys_##name, sys_ni_posix_timers); \ SYSCALL_ALIAS(__x64_sys_##name, sys_ni_posix_timers); \
...@@ -75,15 +92,24 @@ ...@@ -75,15 +92,24 @@
* of the x86-64-style parameter ordering of x32 syscalls. The syscalls common * of the x86-64-style parameter ordering of x32 syscalls. The syscalls common
* with x86_64 obviously do not need such care. * with x86_64 obviously do not need such care.
*/ */
#define __X32_COMPAT_SYS_STUB0(x, name, ...) \
asmlinkage long __x32_compat_sys_##name(const struct pt_regs *regs);\
ALLOW_ERROR_INJECTION(__x32_compat_sys_##name, ERRNO); \
asmlinkage long __x32_compat_sys_##name(const struct pt_regs *regs)\
{ \
return __se_compat_sys_##name();\
}
#define __X32_COMPAT_SYS_STUBx(x, name, ...) \ #define __X32_COMPAT_SYS_STUBx(x, name, ...) \
asmlinkage long __x32_compat_sys##name(const struct pt_regs *regs);\ asmlinkage long __x32_compat_sys##name(const struct pt_regs *regs);\
ALLOW_ERROR_INJECTION(__x32_compat_sys##name, ERRNO); \ ALLOW_ERROR_INJECTION(__x32_compat_sys##name, ERRNO); \
asmlinkage long __x32_compat_sys##name(const struct pt_regs *regs)\ asmlinkage long __x32_compat_sys##name(const struct pt_regs *regs)\
{ \ { \
return __se_compat_sys##name(SC_X86_64_REGS_TO_ARGS(x,__VA_ARGS__));\ return __se_compat_sys##name(SC_X86_64_REGS_TO_ARGS(x,__VA_ARGS__));\
} \ }
#else /* CONFIG_X86_X32 */ #else /* CONFIG_X86_X32 */
#define __X32_COMPAT_SYS_STUB0(x, name)
#define __X32_COMPAT_SYS_STUBx(x, name, ...) #define __X32_COMPAT_SYS_STUBx(x, name, ...)
#endif /* CONFIG_X86_X32 */ #endif /* CONFIG_X86_X32 */
...@@ -94,6 +120,17 @@ ...@@ -94,6 +120,17 @@
* mapping of registers to parameters, we need to generate stubs for each * mapping of registers to parameters, we need to generate stubs for each
* of them. * of them.
*/ */
#define COMPAT_SYSCALL_DEFINE0(name) \
static long __se_compat_sys_##name(void); \
static inline long __do_compat_sys_##name(void); \
__IA32_COMPAT_SYS_STUB0(x, name) \
__X32_COMPAT_SYS_STUB0(x, name) \
static long __se_compat_sys_##name(void) \
{ \
return __do_compat_sys_##name(); \
} \
static inline long __do_compat_sys_##name(void)
#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\ static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
...@@ -183,13 +220,17 @@ ...@@ -183,13 +220,17 @@
#ifndef SYSCALL_DEFINE0 #ifndef SYSCALL_DEFINE0
#define SYSCALL_DEFINE0(sname) \ #define SYSCALL_DEFINE0(sname) \
SYSCALL_METADATA(_##sname, 0); \ SYSCALL_METADATA(_##sname, 0); \
asmlinkage long __x64_sys_##sname(void); \ asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused);\
ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \ ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \
asmlinkage long __x64_sys_##sname(void) asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused)
#endif #endif
#ifndef COND_SYSCALL #ifndef COND_SYSCALL
#define COND_SYSCALL(name) cond_syscall(__x64_sys_##name) #define COND_SYSCALL(name) \
asmlinkage __weak long __x64_sys_##name(const struct pt_regs *__unused) \
{ \
return sys_ni_syscall(); \
}
#endif #endif
#ifndef SYS_NI #ifndef SYS_NI
...@@ -201,7 +242,6 @@ ...@@ -201,7 +242,6 @@
* For VSYSCALLS, we need to declare these three syscalls with the new * For VSYSCALLS, we need to declare these three syscalls with the new
* pt_regs-based calling convention for in-kernel use. * pt_regs-based calling convention for in-kernel use.
*/ */
struct pt_regs;
asmlinkage long __x64_sys_getcpu(const struct pt_regs *regs); asmlinkage long __x64_sys_getcpu(const struct pt_regs *regs);
asmlinkage long __x64_sys_gettimeofday(const struct pt_regs *regs); asmlinkage long __x64_sys_gettimeofday(const struct pt_regs *regs);
asmlinkage long __x64_sys_time(const struct pt_regs *regs); asmlinkage long __x64_sys_time(const struct pt_regs *regs);
......
...@@ -643,8 +643,8 @@ void __native_set_fixmap(enum fixed_addresses idx, pte_t pte) ...@@ -643,8 +643,8 @@ void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
fixmaps_set++; fixmaps_set++;
} }
void native_set_fixmap(enum fixed_addresses idx, phys_addr_t phys, void native_set_fixmap(unsigned /* enum fixed_addresses */ idx,
pgprot_t flags) phys_addr_t phys, pgprot_t flags)
{ {
/* Sanitize 'prot' against any unsupported bits: */ /* Sanitize 'prot' against any unsupported bits: */
pgprot_val(flags) &= __default_kernel_pte_mask; pgprot_val(flags) &= __default_kernel_pte_mask;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment