Skip to content

Commit 9f8f966

Browse files
hongquan-progteburd
authored andcommitted
arch: arm64: fix user-mode stack guard boundary calculation
z_arm64_stack_corruption_check() computed the user-mode stack guard page start by subtracting only Z_ARM64_STACK_GUARD_SIZE from stack_info.start. However, the guard page is located below the privileged stack area, so CONFIG_PRIVILEGED_STACK_SIZE must also be subtracted. Without this, the computed guard_start falls inside the privileged stack instead of the actual guard page, causing stack overflow detection to miss faults in the guard region. Fixes zephyrproject-rtos#113388 Signed-off-by: Hongquan Li <hongquan.li@processmission.com>
1 parent b07d0d1 commit 9f8f966

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/arm64/core/fatal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ static bool z_arm64_stack_corruption_check(struct arch_esf *esf, uint64_t esr, u
435435
#ifdef CONFIG_USERSPACE
436436
else if ((_current->base.user_options & K_USER) != 0 && GET_ESR_EC(esr) == 0x24) {
437437
sp_limit = (uint64_t)_current->stack_info.start;
438-
guard_start = sp_limit - Z_ARM64_STACK_GUARD_SIZE;
438+
guard_start = sp_limit - CONFIG_PRIVILEGED_STACK_SIZE - Z_ARM64_STACK_GUARD_SIZE;
439439
sp = esf->sp;
440440
if (sp <= sp_limit || (guard_start <= far && far <= sp_limit)) {
441441
EXCEPTION_DUMP("STACK OVERFLOW FROM USERSPACE,"

0 commit comments

Comments
 (0)