Commit 22eab110 authored by Dmitry V. Levin's avatar Dmitry V. Levin Committed by Thomas Gleixner

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.

Reported-by: strace/tests/restart_syscall.test
Reported-and-tested-by: default avatarElvira Khabirova <lineprinter0@gmail.com>
Signed-off-by: default avatarDmitry V. Levin <ldv@altlinux.org>
Cc: Elvira Khabirova <lineprinter0@gmail.com>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/20151130215436.GA25996@altlinux.orgSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 8e8efe03
...@@ -690,12 +690,15 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs) ...@@ -690,12 +690,15 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)
signal_setup_done(failed, ksig, stepping); signal_setup_done(failed, ksig, stepping);
} }
#ifdef CONFIG_X86_32 static inline unsigned long get_nr_restart_syscall(const struct pt_regs *regs)
#define NR_restart_syscall __NR_restart_syscall {
#else /* !CONFIG_X86_32 */ #if defined(CONFIG_X86_32) || !defined(CONFIG_X86_64)
#define NR_restart_syscall \ return __NR_restart_syscall;
test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall : __NR_restart_syscall #else /* !CONFIG_X86_32 && CONFIG_X86_64 */
#endif /* CONFIG_X86_32 */ 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 * 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) ...@@ -724,7 +727,7 @@ void do_signal(struct pt_regs *regs)
break; break;
case -ERESTART_RESTARTBLOCK: case -ERESTART_RESTARTBLOCK:
regs->ax = NR_restart_syscall; regs->ax = get_nr_restart_syscall(regs);
regs->ip -= 2; regs->ip -= 2;
break; break;
} }
......
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