arm64_checkstack.c: Fix traversing of user stack when ARCH_ADDRENV=Y

Need to instantiate the correct address environment when reading from
user stack, otherwise the result is very likely a crash
This commit is contained in:
Ville Juven 2024-08-26 16:18:27 +03:00 committed by Xiang Xiao
parent 51c4a5c2d6
commit 12ba2eeb23

View file

@ -198,7 +198,27 @@ void arm64_stack_color(void *stackbase, size_t nbytes)
size_t up_check_tcbstack(struct tcb_s *tcb)
{
return arm64_stack_check(tcb->stack_base_ptr, tcb->adj_stack_size);
size_t size;
#ifdef CONFIG_ARCH_ADDRENV
struct addrenv_s *oldenv;
if (tcb->addrenv_own != NULL)
{
addrenv_select(tcb->addrenv_own, &oldenv);
}
#endif
size = arm64_stack_check(tcb->stack_base_ptr, tcb->adj_stack_size);
#ifdef CONFIG_ARCH_ADDRENV
if (tcb->addrenv_own != NULL)
{
addrenv_restore(oldenv);
}
#endif
return size;
}
#if CONFIG_ARCH_INTERRUPTSTACK > 7