xtensa: use XCHAL_NUM_AREGS as pt_regs::areg size
authorMax Filippov <jcmvbkbc@gmail.com>
Sun, 6 Mar 2022 05:05:54 +0000 (21:05 -0800)
committerMax Filippov <jcmvbkbc@gmail.com>
Mon, 7 Mar 2022 20:02:54 +0000 (12:02 -0800)
commit5b835d4cade1723c5944a231cc685801f5a5cc6c
treec744c4af85ce0ee3c6a83e328cf7b445b5170a88
parent6fad9ddc7d9f6dfb8a53c192f746c26e0d72ee35
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>
arch/xtensa/include/asm/ptrace.h
arch/xtensa/kernel/process.c