Intrepid SRU, LP #339743, [PATCH] x86-64: fix int $0x80 -ENOSYS return

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Intrepid SRU, LP #339743, [PATCH] x86-64: fix int $0x80 -ENOSYS return

Tim Gardner-2
Andy did all the heavy lifting. You could cherry pick this from Jaunty.;a=commit;h=73eec19c0301e46b46184cc8c16704ee6b9e26a5

Tim Gardner [hidden email]

From 73eec19c0301e46b46184cc8c16704ee6b9e26a5 Mon Sep 17 00:00:00 2001
From: Roland McGrath <[hidden email]>
Date: Fri, 6 Feb 2009 18:15:18 -0800
Subject: [PATCH] x86-64: fix int $0x80 -ENOSYS return

Bug: #339743

One of my past fixes to this code introduced a different new bug.
When using 32-bit "int $0x80" entry for a bogus syscall number,
the return value is not correctly set to -ENOSYS.  This only happens
when neither syscall-audit nor syscall tracing is enabled (i.e., never
seen if auditd ever started).  Test program:

        /* gcc -o int80-badsys -m32 -g int80-badsys.c
           Run on x86-64 kernel.
           Note to reproduce the bug you need auditd never to have started.  */

        #include <errno.h>
        #include <stdio.h>

        main (void)
          long res;
          asm ("int $0x80" : "=a" (res) : "0" (99999));
          printf ("bad syscall returns %ld\n", res);
          return res != -ENOSYS;

The fix makes the int $0x80 path match the sysenter and syscall paths.

Reported-by: Dmitry V. Levin <[hidden email]>
Signed-off-by: Roland McGrath <[hidden email]>
Signed-off-by: Tim Gardner <[hidden email]>
 arch/x86/ia32/ia32entry.S |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index 256b00b..5a0d76d 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -418,9 +418,9 @@ ENTRY(ia32_syscall)
  orl   $TS_COMPAT,TI_status(%r10)
  testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10)
  jnz ia32_tracesys
  cmpl $(IA32_NR_syscalls-1),%eax
- ja  int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
+ ja ia32_badsys
  call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
@@ -435,7 +435,9 @@ ia32_tracesys:
  call syscall_trace_enter
  LOAD_ARGS32 ARGOFFSET  /* reload args from stack in case ptrace changed it */
- jmp ia32_do_syscall
+ cmpl $(IA32_NR_syscalls-1),%eax
+ ja  int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
+ jmp ia32_do_call

kernel-team mailing list
[hidden email]