Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/regs: Syscall_get_nr() returns -1 for a non-system call

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

authored by

H. Peter Anvin and committed by
Ingo Molnar
9ddcb87b 29e97589

+3 -3
+1 -1
arch/x86/kernel/ptrace.c
··· 911 911 * syscall with TS_COMPAT still set. 912 912 */ 913 913 regs->orig_ax = value; 914 - if (syscall_get_nr(child, regs) >= 0) 914 + if (syscall_get_nr(child, regs) != -1) 915 915 child->thread_info.status |= TS_I386_REGS_POKED; 916 916 break; 917 917
+2 -2
arch/x86/kernel/signal.c
··· 713 713 save_v86_state((struct kernel_vm86_regs *) regs, VM86_SIGNAL); 714 714 715 715 /* Are we from a system call? */ 716 - if (syscall_get_nr(current, regs) >= 0) { 716 + if (syscall_get_nr(current, regs) != -1) { 717 717 /* If so, check system call restarting.. */ 718 718 switch (syscall_get_error(current, regs)) { 719 719 case -ERESTART_RESTARTBLOCK: ··· 793 793 } 794 794 795 795 /* Did we come from a system call? */ 796 - if (syscall_get_nr(current, regs) >= 0) { 796 + if (syscall_get_nr(current, regs) != -1) { 797 797 /* Restart the system call - no handlers present */ 798 798 switch (syscall_get_error(current, regs)) { 799 799 case -ERESTARTNOHAND: