aac15a121cf9f8b1e52495b9e2e2b0fcc9533e0d
[buildroot.git] /
1 From 35b7ce4f8f290794d3b89db7461e8c568b5defa1 Mon Sep 17 00:00:00 2001
2 From: Khem Raj <raj.khem@gmail.com>
3 Date: Mon, 25 Apr 2016 09:19:17 -0700
4 Subject: powerpc/ptrace: Fix out of bounds array access warning
5
6 commit 1e407ee3b21f981140491d5b8a36422979ca246f upstream.
7
8 gcc-6 correctly warns about a out of bounds access
9
10 arch/powerpc/kernel/ptrace.c:407:24: warning: index 32 denotes an offset greater than size of 'u64[32][1] {aka long long unsigned int[32][1]}' [-Warray-bounds]
11 offsetof(struct thread_fp_state, fpr[32][0]));
12 ^
13
14 check the end of array instead of beginning of next element to fix this
15
16 Signed-off-by: Khem Raj <raj.khem@gmail.com>
17 Cc: Kees Cook <keescook@chromium.org>
18 Cc: Michael Ellerman <mpe@ellerman.id.au>
19 Cc: Segher Boessenkool <segher@kernel.crashing.org>
20 Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
21 Acked-by: Olof Johansson <olof@lixom.net>
22 Cc: Arnd Bergmann <arnd@arndb.de>
23 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25 Signed-off-by: Oleksandr Zhadan <oleks@arcturusnetworks.com>
26 ---
27 arch/powerpc/kernel/ptrace.c | 4 ++--
28 1 file changed, 2 insertions(+), 2 deletions(-)
29
30 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
31 index f21897b..93f200f 100644
32 --- a/arch/powerpc/kernel/ptrace.c
33 +++ b/arch/powerpc/kernel/ptrace.c
34 @@ -376,7 +376,7 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset,
35
36 #else
37 BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
38 - offsetof(struct thread_fp_state, fpr[32][0]));
39 + offsetof(struct thread_fp_state, fpr[32]));
40
41 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
42 &target->thread.fp_state, 0, -1);
43 @@ -404,7 +404,7 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,
44 return 0;
45 #else
46 BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
47 - offsetof(struct thread_fp_state, fpr[32][0]));
48 + offsetof(struct thread_fp_state, fpr[32]));
49
50 return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
51 &target->thread.fp_state, 0, -1);
52 --
53 cgit v1.1