x86/regs: Syscall_get_nr() returns -1 for a non-system call
authorH. Peter Anvin <hpa@zytor.com>
Mon, 10 May 2021 18:53:15 +0000 (11:53 -0700)
committerIngo Molnar <mingo@kernel.org>
Wed, 12 May 2021 08:49:15 +0000 (10:49 +0200)
syscall_get_nr() is defined to return -1 for a non-system call or a
ptrace/seccomp restart; not just any arbitrary number. See comment in
<asm-generic/syscall.h> for the official definition of this function.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210510185316.3307264-7-hpa@zytor.com
arch/x86/kernel/ptrace.c
arch/x86/kernel/signal.c

index 87a4143aa7d7cef390fb62a7c4da7352acf440e7..4c208ea3bd9f3412e3ec5b72b0cb812c07f92c4d 100644 (file)
@@ -911,7 +911,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 value)
                 * syscall with TS_COMPAT still set.
                 */
                regs->orig_ax = value;
-               if (syscall_get_nr(child, regs) >= 0)
+               if (syscall_get_nr(child, regs) != -1)
                        child->thread_info.status |= TS_I386_REGS_POKED;
                break;
 
index a06cb107c0e88e8621cd514d3dd1546979f4bfb7..e12779a2714dce0a141aab191f032964bd57c1bc 100644 (file)
@@ -713,7 +713,7 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)
                save_v86_state((struct kernel_vm86_regs *) regs, VM86_SIGNAL);
 
        /* Are we from a system call? */
-       if (syscall_get_nr(current, regs) >= 0) {
+       if (syscall_get_nr(current, regs) != -1) {
                /* If so, check system call restarting.. */
                switch (syscall_get_error(current, regs)) {
                case -ERESTART_RESTARTBLOCK:
@@ -793,7 +793,7 @@ void arch_do_signal_or_restart(struct pt_regs *regs, bool has_signal)
        }
 
        /* Did we come from a system call? */
-       if (syscall_get_nr(current, regs) >= 0) {
+       if (syscall_get_nr(current, regs) != -1) {
                /* Restart the system call - no handlers present */
                switch (syscall_get_error(current, regs)) {
                case -ERESTARTNOHAND: