From ca981c9faddc0d86fb21d1f55fb2c1847a8ca4e8 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 29 Dec 2003 05:50:32 -0800 Subject: [PATCH] [PATCH] Signal fixes for x86-64 From: Andi Kleen Merge signal race fixes from i386 to x86-64. Fix a bug in system call restart, noted by John Blackwood. --- arch/x86_64/ia32/ia32_signal.c | 3 +++ arch/x86_64/kernel/signal.c | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/x86_64/ia32/ia32_signal.c b/arch/x86_64/ia32/ia32_signal.c index a6642d5a8ddf3..ad6c74c98a3e9 100644 --- a/arch/x86_64/ia32/ia32_signal.c +++ b/arch/x86_64/ia32/ia32_signal.c @@ -173,6 +173,9 @@ ia32_restore_sigcontext(struct pt_regs *regs, struct sigcontext_ia32 *sc, unsign { unsigned int err = 0; + /* Always make any pending restarted system calls return -EINTR */ + current_thread_info()->restart_block.fn = do_no_restart_syscall; + #if DEBUG_SIG printk("SIG restore_sigcontext: sc=%p err(%x) eip(%x) cs(%x) flg(%x)\n", sc, sc->err, sc->eip, sc->cs, sc->eflags); diff --git a/arch/x86_64/kernel/signal.c b/arch/x86_64/kernel/signal.c index 6ae0e7077e09b..ecf0e46d74c56 100644 --- a/arch/x86_64/kernel/signal.c +++ b/arch/x86_64/kernel/signal.c @@ -93,6 +93,8 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext *sc, unsigned long *p { unsigned int err = 0; + /* Always make any pending restarted system calls return -EINTR */ + current_thread_info()->restart_block.fn = do_no_restart_syscall; #define COPY(x) err |= __get_user(regs->x, &sc->x) @@ -355,8 +357,6 @@ handle_signal(unsigned long sig, siginfo_t *info, sigset_t *oldset, /* If so, check system call restarting.. */ switch (regs->rax) { case -ERESTART_RESTARTBLOCK: - current_thread_info()->restart_block.fn = do_no_restart_syscall; - /* FALL THROUGH */ case -ERESTARTNOHAND: regs->rax = -EINTR; break; @@ -371,10 +371,6 @@ handle_signal(unsigned long sig, siginfo_t *info, sigset_t *oldset, regs->rax = regs->orig_rax; regs->rip -= 2; } - if (regs->rax == (unsigned long)-ERESTART_RESTARTBLOCK){ - regs->rax = __NR_restart_syscall; - regs->rip -= 2; - } } #ifdef CONFIG_IA32_EMULATION @@ -453,6 +449,10 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset) regs->rax = regs->orig_rax; regs->rip -= 2; } + if (regs->rax == (unsigned long)-ERESTART_RESTARTBLOCK) { + regs->rax = __NR_restart_syscall; + regs->rip -= 2; + } } return 0; } -- 2.53.0