diff options
author | Mickaël Salaün <mic@digikod.net> | 2015-12-29 15:35:44 -0500 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2016-01-10 15:49:48 -0500 |
commit | e04c989eb785af61d2895d76d38c09166296f9c5 (patch) | |
tree | a4698bceed0851ec151539c275e5d615da506d36 /arch/um/kernel | |
parent | a7df4716d19594b7b3f106f0bc0ca1c548e508e6 (diff) |
um: Fix ptrace GETREGS/SETREGS bugs
This fix two related bugs:
* PTRACE_GETREGS doesn't get the right orig_ax (syscall) value
* PTRACE_SETREGS can't set the orig_ax value (erased by initial value)
Get rid of the now useless and error-prone get_syscall().
Fix inconsistent behavior in the ptrace implementation for i386 when
updating orig_eax automatically update the syscall number as well. This
is now updated in handle_syscall().
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kees Cook <keescook@chromium.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Will Drewry <wad@chromium.org>
Cc: Thomas Meyer <thomas@m3y3r.de>
Cc: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Cc: Anton Ivanov <aivanov@brocade.com>
Cc: Meredydd Luff <meredydd@senatehouse.org>
Cc: David Drysdale <drysdale@google.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'arch/um/kernel')
-rw-r--r-- | arch/um/kernel/skas/syscall.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/arch/um/kernel/skas/syscall.c b/arch/um/kernel/skas/syscall.c index 1683b8efdfda..6cadce761bcf 100644 --- a/arch/um/kernel/skas/syscall.c +++ b/arch/um/kernel/skas/syscall.c | |||
@@ -7,29 +7,31 @@ | |||
7 | #include <linux/ptrace.h> | 7 | #include <linux/ptrace.h> |
8 | #include <kern_util.h> | 8 | #include <kern_util.h> |
9 | #include <sysdep/ptrace.h> | 9 | #include <sysdep/ptrace.h> |
10 | #include <sysdep/ptrace_user.h> | ||
10 | #include <sysdep/syscalls.h> | 11 | #include <sysdep/syscalls.h> |
11 | #include <os.h> | ||
12 | 12 | ||
13 | void handle_syscall(struct uml_pt_regs *r) | 13 | void handle_syscall(struct uml_pt_regs *r) |
14 | { | 14 | { |
15 | struct pt_regs *regs = container_of(r, struct pt_regs, regs); | 15 | struct pt_regs *regs = container_of(r, struct pt_regs, regs); |
16 | long result; | ||
17 | int syscall; | 16 | int syscall; |
18 | 17 | ||
19 | if (syscall_trace_enter(regs)) { | 18 | /* Initialize the syscall number and default return value. */ |
20 | result = -ENOSYS; | 19 | UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp); |
20 | PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS); | ||
21 | |||
22 | if (syscall_trace_enter(regs)) | ||
21 | goto out; | 23 | goto out; |
22 | } | ||
23 | 24 | ||
24 | syscall = get_syscall(r); | 25 | /* Update the syscall number after orig_ax has potentially been updated |
26 | * with ptrace. | ||
27 | */ | ||
28 | UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp); | ||
29 | syscall = UPT_SYSCALL_NR(r); | ||
25 | 30 | ||
26 | if ((syscall > __NR_syscall_max) || syscall < 0) | 31 | if (syscall >= 0 && syscall <= __NR_syscall_max) |
27 | result = -ENOSYS; | 32 | PT_REGS_SET_SYSCALL_RETURN(regs, |
28 | else | 33 | EXECUTE_SYSCALL(syscall, regs)); |
29 | result = EXECUTE_SYSCALL(syscall, regs); | ||
30 | 34 | ||
31 | out: | 35 | out: |
32 | PT_REGS_SET_SYSCALL_RETURN(regs, result); | ||
33 | |||
34 | syscall_trace_leave(regs); | 36 | syscall_trace_leave(regs); |
35 | } | 37 | } |