Browse Source

userspace: dynamic: Fix k_thread_stack_free verification

k_thread_stack_free syscall was not checking if the caller
had permission to given stack object.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
pull/73044/head
Flavio Ceolin 1 year ago committed by Anas Nashif
parent
commit
c12f0507b6
  1. 9
      kernel/dynamic.c

9
kernel/dynamic.c

@ -166,6 +166,15 @@ int z_impl_k_thread_stack_free(k_thread_stack_t *stack) @@ -166,6 +166,15 @@ int z_impl_k_thread_stack_free(k_thread_stack_t *stack)
#ifdef CONFIG_USERSPACE
static inline int z_vrfy_k_thread_stack_free(k_thread_stack_t *stack)
{
/* The thread stack object must not be in initialized state.
*
* Thread stack objects are initialized when the thread is created
* and de-initialized whent the thread is destroyed. Since we can't
* free a stack that is in use, we have to check that the caller
* has access to the object but that it is not in use anymore.
*/
K_OOPS(K_SYSCALL_OBJ_NEVER_INIT(stack, K_OBJ_THREAD_STACK_ELEMENT));
return z_impl_k_thread_stack_free(stack);
}
#include <syscalls/k_thread_stack_free_mrsh.c>

Loading…
Cancel
Save