Skip to content

Commit 9ddcb87

Browse files
H. Peter Anviningomolnar
authored andcommitted
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
1 parent 29e9758 commit 9ddcb87

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

arch/x86/kernel/ptrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 value)
911911
* syscall with TS_COMPAT still set.
912912
*/
913913
regs->orig_ax = value;
914-
if (syscall_get_nr(child, regs) >= 0)
914+
if (syscall_get_nr(child, regs) != -1)
915915
child->thread_info.status |= TS_I386_REGS_POKED;
916916
break;
917917

arch/x86/kernel/signal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)
713713
save_v86_state((struct kernel_vm86_regs *) regs, VM86_SIGNAL);
714714

715715
/* Are we from a system call? */
716-
if (syscall_get_nr(current, regs) >= 0) {
716+
if (syscall_get_nr(current, regs) != -1) {
717717
/* If so, check system call restarting.. */
718718
switch (syscall_get_error(current, regs)) {
719719
case -ERESTART_RESTARTBLOCK:
@@ -793,7 +793,7 @@ void arch_do_signal_or_restart(struct pt_regs *regs, bool has_signal)
793793
}
794794

795795
/* Did we come from a system call? */
796-
if (syscall_get_nr(current, regs) >= 0) {
796+
if (syscall_get_nr(current, regs) != -1) {
797797
/* Restart the system call - no handlers present */
798798
switch (syscall_get_error(current, regs)) {
799799
case -ERESTARTNOHAND:

0 commit comments

Comments
 (0)