x86/signal: fix restart_syscall number for x32 tasks
PATCH 1/1 x86/signal: fix restart_syscall number for x32 tasks
When restarting a syscall with regs->ax == -ERESTART_RESTARTBLOCK, regs->ax is assigned to a restart_syscall number. For x32 tasks, this syscall number must have __X32_SYSCALL_BIT set, otherwise it will be an x86_64 syscall number instead of a valid x32 syscall number.
--- arch/x86/kernel/signal.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
arch/x86/kernel/signal.c +10 -7
@@ -690,12 +690,15 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)signal_setup_done (failed, ksig, stepping); } -#ifdef CONFIG_X86_32 -#define NR_restart_syscall __NR_restart_syscall -#else /* !CONFIG_X86_32 */ -#define NR_restart_syscall \ - test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall : __NR_restart_syscall -#endif /* CONFIG_X86_32 */ +static inline unsigned long get_nr_restart_syscall (const struct pt_regs *regs) +{ +#if defined(CONFIG_X86_32 ) || !defined(CONFIG_X86_64 ) +return __NR_restart_syscall; +#else /* !CONFIG_X86_32 && CONFIG_X86_64 */ +return test_thread_flag (TIF_IA32 ) ? __NR_ia32_restart_syscall : + __NR_restart_syscall | (regs->orig_ax & __X32_SYSCALL_BIT); +#endif /* CONFIG_X86_32 || !CONFIG_X86_64 */ +}/* * Note that 'init' is a special process: it doesn't get signals it doesn't
@@ -724,7 +727,7 @@ void do_signal(struct pt_regs *regs)break ;case -ERESTART_RESTARTBLOCK : - regs->ax = NR_restart_syscall; + regs->ax =get_nr_restart_syscall (regs); regs->ip -=2 ;break ; }
Signature · 1 line
ldv
tip-bot for Dmitry V. Levin
merge bot[tip:x86/urgent] x86/signal: Fix restart_syscall number for x32 tasks
x86/signal: Fix restart_syscall number for x32 tasks
Commit-ID: 22eab1108781eff09961ae7001704f7bd8fb1dce Gitweb: http://git.kernel.org/tip/22eab1108781eff09961ae7001704f7bd8fb1dce Author: Dmitry V. Levin <[email protected]> AuthorDate: Tue, 1 Dec 2015 00:54:36 +0300 Committer: Thomas Gleixner <[email protected]> CommitDate: Sat, 5 Dec 2015 18:52:14 +0100
x86/signal: Fix restart_syscall number for x32 tasks
When restarting a syscall with regs->ax == -ERESTART_RESTARTBLOCK, regs->ax is assigned to a restart_syscall number. For x32 tasks, this syscall number must have __X32_SYSCALL_BIT set, otherwise it will be an x86_64 syscall number instead of a valid x32 syscall number. This issue has been there since the introduction of x32.
--- arch/x86/kernel/signal.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
arch/x86/kernel/signal.c +10 -7
@@ -690,12 +690,15 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)signal_setup_done (failed, ksig, stepping); } -#ifdef CONFIG_X86_32 -#define NR_restart_syscall __NR_restart_syscall -#else /* !CONFIG_X86_32 */ -#define NR_restart_syscall \ - test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall : __NR_restart_syscall -#endif /* CONFIG_X86_32 */ +static inline unsigned long get_nr_restart_syscall (const struct pt_regs *regs) +{ +#if defined(CONFIG_X86_32 ) || !defined(CONFIG_X86_64 ) +return __NR_restart_syscall; +#else /* !CONFIG_X86_32 && CONFIG_X86_64 */ +return test_thread_flag (TIF_IA32 ) ? __NR_ia32_restart_syscall : + __NR_restart_syscall | (regs->orig_ax & __X32_SYSCALL_BIT); +#endif /* CONFIG_X86_32 || !CONFIG_X86_64 */ +}/* * Note that 'init' is a special process: it doesn't get signals it doesn't
@@ -724,7 +727,7 @@ void do_signal(struct pt_regs *regs)break ;case -ERESTART_RESTARTBLOCK : - regs->ax = NR_restart_syscall; + regs->ax =get_nr_restart_syscall (regs); regs->ip -=2 ;break ; }