aboutsummaryrefslogtreecommitdiff
path: root/arch/xtensa/include/asm
diff options
context:
space:
mode:
authorGravatar Max Filippov <jcmvbkbc@gmail.com> 2022-03-05 21:05:54 -0800
committerGravatar Max Filippov <jcmvbkbc@gmail.com> 2022-03-07 12:02:54 -0800
commit5b835d4cade1723c5944a231cc685801f5a5cc6c (patch)
treec744c4af85ce0ee3c6a83e328cf7b445b5170a88 /arch/xtensa/include/asm
parentxtensa: rename PT_SIZE to PT_KERNEL_SIZE (diff)
downloadlinux-5b835d4cade1723c5944a231cc685801f5a5cc6c.tar.gz
linux-5b835d4cade1723c5944a231cc685801f5a5cc6c.tar.bz2
linux-5b835d4cade1723c5944a231cc685801f5a5cc6c.zip
xtensa: use XCHAL_NUM_AREGS as pt_regs::areg size
struct pt_regs is used to access both kernel and user exception frames. User exception frames may contain up to XCHAL_NUM_AREG registers that task creation and signal delivery code may access, but pt_regs::areg array has only 16 entries that cover only the kernel exception frame. This results in the following build error: arch/xtensa/kernel/process.c: In function 'copy_thread': arch/xtensa/kernel/process.c:262:52: error: array subscript 53 is above array bounds of 'long unsigned int[16]' [-Werror=array-bounds] 262 | put_user(regs->areg[caller_ars+1], Change struct pt_regs::areg size to XCHAL_NUM_AREGS so that it covers the whole user exception frame. Adjust task_pt_regs and drop additional register copying code from copy_thread now that the whole user exception stack frame is copied. Reported-by: Kees Cook <keescook@chromium.org> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Reviewed-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'arch/xtensa/include/asm')
-rw-r--r--arch/xtensa/include/asm/ptrace.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/arch/xtensa/include/asm/ptrace.h b/arch/xtensa/include/asm/ptrace.h
index b109416dc07e..308f209a4740 100644
--- a/arch/xtensa/include/asm/ptrace.h
+++ b/arch/xtensa/include/asm/ptrace.h
@@ -44,6 +44,7 @@
#ifndef __ASSEMBLY__
#include <asm/coprocessor.h>
+#include <asm/core.h>
/*
* This struct defines the way the registers are stored on the
@@ -77,14 +78,12 @@ struct pt_regs {
/* current register frame.
* Note: The ESF for kernel exceptions ends after 16 registers!
*/
- unsigned long areg[16];
+ unsigned long areg[XCHAL_NUM_AREGS];
};
-#include <asm/core.h>
-
# define arch_has_single_step() (1)
# define task_pt_regs(tsk) ((struct pt_regs*) \
- (task_stack_page(tsk) + KERNEL_STACK_SIZE - (XCHAL_NUM_AREGS-16)*4) - 1)
+ (task_stack_page(tsk) + KERNEL_STACK_SIZE) - 1)
# define user_mode(regs) (((regs)->ps & 0x00000020)!=0)
# define instruction_pointer(regs) ((regs)->pc)
# define return_pointer(regs) (MAKE_PC_FROM_RA((regs)->areg[0], \