diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2020-07-23 00:00:04 +0200 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2020-07-24 15:04:59 +0200 |
commit | 27d6b4d14f5c3ab21c4aef87dd04055a2d7adf14 (patch) | |
tree | ff1aaa49f6efd1be5955afd50c0e22423352b6d9 /arch/x86/include/asm/entry-common.h | |
parent | 0bf019ea59e330770883ede4499d7f711d8c3adf (diff) | |
download | linux-stable-27d6b4d14f5c3ab21c4aef87dd04055a2d7adf14.tar.gz linux-stable-27d6b4d14f5c3ab21c4aef87dd04055a2d7adf14.tar.bz2 linux-stable-27d6b4d14f5c3ab21c4aef87dd04055a2d7adf14.zip |
x86/entry: Use generic syscall entry function
Replace the syscall entry work handling with the generic version. Provide
the necessary helper inlines to handle the real architecture specific
parts, e.g. ptrace.
Use a temporary define for idtentry_enter_user which will be cleaned up
seperately.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lkml.kernel.org/r/20200722220520.376213694@linutronix.de
Diffstat (limited to 'arch/x86/include/asm/entry-common.h')
-rw-r--r-- | arch/x86/include/asm/entry-common.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/arch/x86/include/asm/entry-common.h b/arch/x86/include/asm/entry-common.h new file mode 100644 index 000000000000..7070b90c8312 --- /dev/null +++ b/arch/x86/include/asm/entry-common.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _ASM_X86_ENTRY_COMMON_H +#define _ASM_X86_ENTRY_COMMON_H + +/* Check that the stack and regs on entry from user mode are sane. */ +static __always_inline void arch_check_user_regs(struct pt_regs *regs) +{ + if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) { + /* + * Make sure that the entry code gave us a sensible EFLAGS + * register. Native because we want to check the actual CPU + * state, not the interrupt state as imagined by Xen. + */ + unsigned long flags = native_save_fl(); + WARN_ON_ONCE(flags & (X86_EFLAGS_AC | X86_EFLAGS_DF | + X86_EFLAGS_NT)); + + /* We think we came from user mode. Make sure pt_regs agrees. */ + WARN_ON_ONCE(!user_mode(regs)); + + /* + * All entries from user mode (except #DF) should be on the + * normal thread stack and should have user pt_regs in the + * correct location. + */ + WARN_ON_ONCE(!on_thread_stack()); + WARN_ON_ONCE(regs != task_pt_regs(current)); + } +} +#define arch_check_user_regs arch_check_user_regs + +#endif |