2008-07-22 00:04:13 +08:00
|
|
|
/*
|
|
|
|
* syscalls.h - Linux syscall interfaces (arch-specific)
|
|
|
|
*
|
2009-04-11 02:33:10 +08:00
|
|
|
* Copyright (c) 2008 Jaswinder Singh Rajput
|
2008-07-22 00:04:13 +08:00
|
|
|
*
|
|
|
|
* This file is released under the GPLv2.
|
|
|
|
* See the file COPYING for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ASM_X86_SYSCALLS_H
|
|
|
|
#define _ASM_X86_SYSCALLS_H
|
|
|
|
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <linux/linkage.h>
|
|
|
|
#include <linux/signal.h>
|
2009-04-11 02:33:10 +08:00
|
|
|
#include <linux/types.h>
|
2008-07-22 00:04:13 +08:00
|
|
|
|
|
|
|
/* Common in X86_32 and X86_64 */
|
|
|
|
/* kernel/ioport.c */
|
2018-03-11 18:34:38 +08:00
|
|
|
long ksys_ioperm(unsigned long from, unsigned long num, int turn_on);
|
syscalls/x86: Use 'struct pt_regs' based syscall calling convention for 64-bit syscalls
Let's make use of ARCH_HAS_SYSCALL_WRAPPER=y on pure 64-bit x86-64 systems:
Each syscall defines a stub which takes struct pt_regs as its only
argument. It decodes just those parameters it needs, e.g:
asmlinkage long sys_xyzzy(const struct pt_regs *regs)
{
return SyS_xyzzy(regs->di, regs->si, regs->dx);
}
This approach avoids leaking random user-provided register content down
the call chain.
For example, for sys_recv() which is a 4-parameter syscall, the assembly
now is (in slightly reordered fashion):
<sys_recv>:
callq <__fentry__>
/* decode regs->di, ->si, ->dx and ->r10 */
mov 0x70(%rdi),%rdi
mov 0x68(%rdi),%rsi
mov 0x60(%rdi),%rdx
mov 0x38(%rdi),%rcx
[ SyS_recv() is automatically inlined by the compiler,
as it is not [yet] used anywhere else ]
/* clear %r9 and %r8, the 5th and 6th args */
xor %r9d,%r9d
xor %r8d,%r8d
/* do the actual work */
callq __sys_recvfrom
/* cleanup and return */
cltq
retq
The only valid place in an x86-64 kernel which rightfully calls
a syscall function on its own -- vsyscall -- needs to be modified
to pass struct pt_regs onwards as well.
To keep the syscall table generation working independent of
SYSCALL_PTREGS being enabled, the stubs are named the same as the
"original" syscall stubs, i.e. sys_*().
This patch is based on an original proof-of-concept
| From: Linus Torvalds <torvalds@linux-foundation.org>
| Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
and was split up and heavily modified by me, in particular to base it on
ARCH_HAS_SYSCALL_WRAPPER, to limit it to 64-bit-only for the time being,
and to update the vsyscall to the new calling convention.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20180405095307.3730-4-linux@dominikbrodowski.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-04-05 17:53:02 +08:00
|
|
|
|
|
|
|
#ifndef CONFIG_SYSCALL_PTREGS
|
|
|
|
/*
|
|
|
|
* If CONFIG_SYSCALL_PTREGS is enabled, a different syscall calling convention
|
|
|
|
* is used. Do not include these -- invalid -- prototypes then
|
|
|
|
*/
|
2008-07-22 00:04:13 +08:00
|
|
|
asmlinkage long sys_ioperm(unsigned long, unsigned long, int);
|
2012-11-20 11:00:52 +08:00
|
|
|
asmlinkage long sys_iopl(unsigned int);
|
2008-07-22 00:04:13 +08:00
|
|
|
|
2008-12-16 00:56:30 +08:00
|
|
|
/* kernel/ldt.c */
|
2017-10-19 01:21:07 +08:00
|
|
|
asmlinkage long sys_modify_ldt(int, void __user *, unsigned long);
|
2008-12-16 00:56:30 +08:00
|
|
|
|
2009-04-11 02:33:10 +08:00
|
|
|
/* kernel/signal.c */
|
2013-08-06 06:02:40 +08:00
|
|
|
asmlinkage long sys_rt_sigreturn(void);
|
2009-04-11 02:33:10 +08:00
|
|
|
|
2008-12-18 01:48:52 +08:00
|
|
|
/* kernel/tls.c */
|
2013-01-22 04:25:54 +08:00
|
|
|
asmlinkage long sys_set_thread_area(struct user_desc __user *);
|
|
|
|
asmlinkage long sys_get_thread_area(struct user_desc __user *);
|
2008-12-18 01:48:52 +08:00
|
|
|
|
2008-07-22 00:04:13 +08:00
|
|
|
/* X86_32 only */
|
|
|
|
#ifdef CONFIG_X86_32
|
|
|
|
|
2009-04-11 02:33:10 +08:00
|
|
|
/* kernel/signal.c */
|
2018-03-22 15:29:36 +08:00
|
|
|
asmlinkage long sys_sigreturn(void);
|
2008-07-22 00:04:13 +08:00
|
|
|
|
2008-07-23 20:01:02 +08:00
|
|
|
/* kernel/vm86_32.c */
|
2015-07-29 13:41:21 +08:00
|
|
|
struct vm86_struct;
|
2013-03-28 05:18:05 +08:00
|
|
|
asmlinkage long sys_vm86old(struct vm86_struct __user *);
|
|
|
|
asmlinkage long sys_vm86(unsigned long, unsigned long);
|
2008-07-23 20:01:02 +08:00
|
|
|
|
2008-07-22 00:04:13 +08:00
|
|
|
#else /* CONFIG_X86_32 */
|
|
|
|
|
|
|
|
/* X86_64 only */
|
|
|
|
/* kernel/process_64.c */
|
2013-08-06 06:02:40 +08:00
|
|
|
asmlinkage long sys_arch_prctl(int, unsigned long);
|
2008-07-22 00:04:13 +08:00
|
|
|
|
|
|
|
/* kernel/sys_x86_64.c */
|
|
|
|
asmlinkage long sys_mmap(unsigned long, unsigned long, unsigned long,
|
|
|
|
unsigned long, unsigned long, unsigned long);
|
|
|
|
|
|
|
|
#endif /* CONFIG_X86_32 */
|
syscalls/x86: Use 'struct pt_regs' based syscall calling convention for 64-bit syscalls
Let's make use of ARCH_HAS_SYSCALL_WRAPPER=y on pure 64-bit x86-64 systems:
Each syscall defines a stub which takes struct pt_regs as its only
argument. It decodes just those parameters it needs, e.g:
asmlinkage long sys_xyzzy(const struct pt_regs *regs)
{
return SyS_xyzzy(regs->di, regs->si, regs->dx);
}
This approach avoids leaking random user-provided register content down
the call chain.
For example, for sys_recv() which is a 4-parameter syscall, the assembly
now is (in slightly reordered fashion):
<sys_recv>:
callq <__fentry__>
/* decode regs->di, ->si, ->dx and ->r10 */
mov 0x70(%rdi),%rdi
mov 0x68(%rdi),%rsi
mov 0x60(%rdi),%rdx
mov 0x38(%rdi),%rcx
[ SyS_recv() is automatically inlined by the compiler,
as it is not [yet] used anywhere else ]
/* clear %r9 and %r8, the 5th and 6th args */
xor %r9d,%r9d
xor %r8d,%r8d
/* do the actual work */
callq __sys_recvfrom
/* cleanup and return */
cltq
retq
The only valid place in an x86-64 kernel which rightfully calls
a syscall function on its own -- vsyscall -- needs to be modified
to pass struct pt_regs onwards as well.
To keep the syscall table generation working independent of
SYSCALL_PTREGS being enabled, the stubs are named the same as the
"original" syscall stubs, i.e. sys_*().
This patch is based on an original proof-of-concept
| From: Linus Torvalds <torvalds@linux-foundation.org>
| Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
and was split up and heavily modified by me, in particular to base it on
ARCH_HAS_SYSCALL_WRAPPER, to limit it to 64-bit-only for the time being,
and to update the vsyscall to the new calling convention.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20180405095307.3730-4-linux@dominikbrodowski.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-04-05 17:53:02 +08:00
|
|
|
#endif /* CONFIG_SYSCALL_PTREGS */
|
2008-07-22 00:04:13 +08:00
|
|
|
#endif /* _ASM_X86_SYSCALLS_H */
|