0003-powerpc-ptrace-Fix-out-of-bounds-array-access-warning.patch 2.1 KB

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