From a6c834edb3064cff2bee1671ea5dd893f60b84b3 Mon Sep 17 00:00:00 2001 From: Ioannis Glaropoulos Date: Tue, 11 Jun 2019 21:03:18 +0200 Subject: [PATCH] arch: arm: fix start of MPU guard in stack-fail check (no user mode) When building without support for user mode (CONFIG_USERSPACE=n) we need to correct the starting address of the MPU Guard, before passing it to the function that evaluates whether a stack corruption has occurred. The bug was introduced by commit (60bae5de38e3aadb70312882cb81bde4e87ffaf9) in PR-13619, where the start address of the MPU guard was properly corrected, but the guard start at the corresponding stack-fail check was not adjusted accordingly. Signed-off-by: Ioannis Glaropoulos --- arch/arm/core/thread.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/core/thread.c b/arch/arm/core/thread.c index 4a54ebadecd88..397db123faf12 100644 --- a/arch/arm/core/thread.c +++ b/arch/arm/core/thread.c @@ -287,11 +287,11 @@ u32_t z_check_thread_stack_fail(const u32_t fault_addr, const u32_t psp) } } #else /* CONFIG_USERSPACE */ - if (IS_MPU_GUARD_VIOLATION(thread->stack_info.start, + if (IS_MPU_GUARD_VIOLATION(thread->stack_info.start - + MPU_GUARD_ALIGN_AND_SIZE, fault_addr, psp)) { /* Thread stack corruption */ - return thread->stack_info.start + - MPU_GUARD_ALIGN_AND_SIZE; + return thread->stack_info.start; } #endif /* CONFIG_USERSPACE */