]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/mips-scall64-o32-fix-indirect-syscall-number-load.patch
4.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.4 / mips-scall64-o32-fix-indirect-syscall-number-load.patch
1 From 79b4a9cf0e2ea8203ce777c8d5cfa86c71eae86e Mon Sep 17 00:00:00 2001
2 From: Aurelien Jarno <aurelien@aurel32.net>
3 Date: Tue, 9 Apr 2019 16:53:55 +0200
4 Subject: MIPS: scall64-o32: Fix indirect syscall number load
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Aurelien Jarno <aurelien@aurel32.net>
10
11 commit 79b4a9cf0e2ea8203ce777c8d5cfa86c71eae86e upstream.
12
13 Commit 4c21b8fd8f14 (MIPS: seccomp: Handle indirect system calls (o32))
14 added indirect syscall detection for O32 processes running on MIPS64,
15 but it did not work correctly for big endian kernel/processes. The
16 reason is that the syscall number is loaded from ARG1 using the lw
17 instruction while this is a 64-bit value, so zero is loaded instead of
18 the syscall number.
19
20 Fix the code by using the ld instruction instead. When running a 32-bit
21 processes on a 64 bit CPU, the values are properly sign-extended, so it
22 ensures the value passed to syscall_trace_enter is correct.
23
24 Recent systemd versions with seccomp enabled whitelist the getpid
25 syscall for their internal processes (e.g. systemd-journald), but call
26 it through syscall(SYS_getpid). This fix therefore allows O32 big endian
27 systems with a 64-bit kernel to run recent systemd versions.
28
29 Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
30 Cc: <stable@vger.kernel.org> # v3.15+
31 Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
32 Signed-off-by: Paul Burton <paul.burton@mips.com>
33 Cc: Ralf Baechle <ralf@linux-mips.org>
34 Cc: James Hogan <jhogan@kernel.org>
35 Cc: linux-mips@vger.kernel.org
36 Cc: linux-kernel@vger.kernel.org
37 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
38
39 ---
40 arch/mips/kernel/scall64-o32.S | 2 +-
41 1 file changed, 1 insertion(+), 1 deletion(-)
42
43 --- a/arch/mips/kernel/scall64-o32.S
44 +++ b/arch/mips/kernel/scall64-o32.S
45 @@ -126,7 +126,7 @@ trace_a_syscall:
46 subu t1, v0, __NR_O32_Linux
47 move a1, v0
48 bnez t1, 1f /* __NR_syscall at offset 0 */
49 - lw a1, PT_R4(sp) /* Arg1 for __NR_syscall case */
50 + ld a1, PT_R4(sp) /* Arg1 for __NR_syscall case */
51 .set pop
52
53 1: jal syscall_trace_enter