Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
kobject.c File Reference
#include "mem_protect.h"
#include <syscall_handler.h>

Functions

 K_THREAD_STACK_DEFINE (child_stack,(512+CONFIG_TEST_EXTRA_STACKSIZE))
 
 K_THREAD_STACK_DEFINE (extra_stack,(512+CONFIG_TEST_EXTRA_STACKSIZE))
 
 K_SEM_DEFINE (kobject_sem,(0),(10))
 
 K_SEM_DEFINE (kobject_public_sem,(0),(10))
 
 K_MUTEX_DEFINE (kobject_mutex)
 
static void kobject_access_grant_user_part (void *p1, void *p2, void *p3)
 
void test_kobject_access_grant (void)
 Test access to a invalid semaphore who's address is NULL. More...
 
void test_kobject_access_grant_error (void)
 Test grant access of given NULL kobject. More...
 
void test_kobject_access_grant_error_user (void)
 Test grant access of given NULL thread in usermode. More...
 
void test_kobject_access_grant_error_user_null (void)
 Test grant access of given NULL kobject in usermode. More...
 
void test_kobject_access_all_grant_error (void)
 Test grant access to all the kobject for thread. More...
 
static void syscall_invalid_kobject_user_part (void *p1, void *p2, void *p3)
 
void test_syscall_invalid_kobject (void)
 Test syscall can take a different type of kobject. More...
 
static void thread_without_kobject_permission_user_part (void *p1, void *p2, void *p3)
 
void test_thread_without_kobject_permission (void)
 Test user thread can access a k_object without grant. More...
 
static void kobject_revoke_access_user_part (void *p1, void *p2, void *p3)
 
void test_kobject_revoke_access (void)
 Test access revoke. More...
 
static void kobject_grant_access_child_entry (void *p1, void *p2, void *p3)
 
static void kobject_grant_access_extra_entry (void *p1, void *p2, void *p3)
 
void test_kobject_grant_access_kobj (void)
 Test access revoke. More...
 
static void grant_access_kobj_invalid_child (void *p1, void *p2, void *p3)
 
void test_kobject_grant_access_kobj_invalid (void)
 Test access grant between threads. More...
 
static void release_from_user_child (void *p1, void *p2, void *p3)
 
void test_kobject_release_from_user (void)
 Test revoke permission of a k_object from userspace. More...
 
void test_kobject_release_null (void)
 
static void access_all_grant_child_give (void *p1, void *p2, void *p3)
 
static void access_all_grant_child_take (void *p1, void *p2, void *p3)
 
void test_kobject_access_all_grant (void)
 Test supervisor thread grants kernel objects all access public status. More...
 
static void residual_permissions_child_success (void *p1, void *p2, void *p3)
 
static void residual_permissions_child_fail (void *p1, void *p2, void *p3)
 
void test_thread_has_residual_permissions (void)
 Test access permission of a terminated thread. More...
 
void test_kobject_access_grant_to_invalid_thread (void)
 Test grant access to a valid kobject but invalid thread id. More...
 
void test_kobject_access_invalid_kobject (void)
 Object validation checks. More...
 
void test_access_kobject_without_init_access (void)
 Object validation checks without init access. More...
 
static void without_init_with_access_child (void *p1, void *p2, void *p3)
 
void test_access_kobject_without_init_with_access (void)
 Test syscall on a kobject which is not initialized and has access. More...
 
static void reinitialize_thread_kobj_extra (void *p1, void *p2, void *p3)
 
static void reinitialize_thread_kobj_child (void *p1, void *p2, void *p3)
 
void test_kobject_reinitialize_thread_kobj (void)
 Test to reinitialize the k_thread object. More...
 
static void new_thread_from_user_extra (void *p1, void *p2, void *p3)
 
static void new_thread_from_user_child (void *p1, void *p2, void *p3)
 
void test_create_new_thread_from_user (void)
 Test thread create from a user thread and check permissions. More...
 
static void new_thrd_from_user_with_in_use_stack (void *p1, void *p2, void *p3)
 
static void new_user_thrd_child_with_in_use_stack (void *p1, void *p2, void *p3)
 
void test_new_user_thread_with_in_use_stack_obj (void)
 Test create new user thread from a user thread with in-use stack obj. More...
 
static void from_user_no_access_stack_extra_entry (void *p1, void *p2, void *p3)
 
static void from_user_no_access_stack_child_entry (void *p1, void *p2, void *p3)
 
void test_create_new_thread_from_user_no_access_stack (void)
 Test creates new thread from usermode without stack access. More...
 
static void from_user_invalid_stacksize_extra (void *p1, void *p2, void *p3)
 
static void from_user_invalid_stacksize_child (void *p1, void *p2, void *p3)
 
void test_create_new_thread_from_user_invalid_stacksize (void)
 Test to validate user thread spawning with stack overflow. More...
 
static void user_huge_stacksize_extra (void *p1, void *p2, void *p3)
 
static void user_huge_stacksize_child (void *p1, void *p2, void *p3)
 
void test_create_new_thread_from_user_huge_stacksize (void)
 Test to check stack overflow from user thread. More...
 
static void supervisor_from_user_extra (void *p1, void *p2, void *p3)
 
static void supervisor_from_user_child (void *p1, void *p2, void *p3)
 
void test_create_new_supervisor_thread_from_user (void)
 Test to create a new supervisor thread from user. More...
 
static void essential_thread_from_user_extra (void *p1, void *p2, void *p3)
 
static void essential_thread_from_user_child (void *p1, void *p2, void *p3)
 
void test_create_new_essential_thread_from_user (void)
 Create a new essential thread from user. More...
 
static void higher_prio_from_user_extra (void *p1, void *p2, void *p3)
 
static void higher_prio_from_user_child (void *p1, void *p2, void *p3)
 
void test_create_new_higher_prio_thread_from_user (void)
 Thread creation with prority is higher than current thread. More...
 
static void invalid_prio_from_user_extra (void *p1, void *p2, void *p3)
 
static void invalid_prio_from_user_child (void *p1, void *p2, void *p3)
 
void test_create_new_invalid_prio_thread_from_user (void)
 Create a new thread whose prority is invalid. More...
 
static void thread_stack_init_objects (void *p1, void *p2, void *p3)
 
void test_mark_thread_exit_uninitialized (void)
 Test when thread exits, kernel marks stack objects uninitialized. More...
 
static void tThread_object_free_error (void *p1, void *p2, void *p3)
 
void test_kobject_free_error (void)
 Test free an invalid kernel object. More...
 
void test_kobject_init_error (void)
 Test alloc an invalid kernel object. More...
 
void test_kobj_create_out_of_memory (void)
 Test kernel object until out of memory. More...
 
void test_thread_alloc_out_of_idx (void)
 
void test_alloc_kobjects (void)
 Test kernel object allocation. More...
 
static void entry_error_perm (void *p1, void *p2, void *p3)
 
void test_kobject_perm_error (void)
 Test grant access failed in user mode. More...
 

Variables

struct k_thread child_thread
 
struct k_thread extra_thread
 
struct k_sem * random_sem_type
 
struct k_sem kobject_sem_not_hash_table
 
struct k_sem kobject_sem_no_init_no_access
 
struct k_sem kobject_sem_no_init_access
 
struct k_mem_slab ms
 
struct k_msgq mq
 
struct k_mutex mutex
 
struct k_pipe p
 
struct k_queue q
 
struct k_poll_signal ps
 
struct k_sem sem
 
struct k_stack s
 
struct k_thread t
 
struct k_timer timer
 
struct z_thread_stack_element zs
 
struct k_futex f
 
struct k_condvar c
 

Function Documentation

◆ access_all_grant_child_give()

static void access_all_grant_child_give ( void p1,
void p2,
void p3 
)
static

◆ access_all_grant_child_take()

static void access_all_grant_child_take ( void p1,
void p2,
void p3 
)
static

◆ entry_error_perm()

static void entry_error_perm ( void p1,
void p2,
void p3 
)
static

◆ essential_thread_from_user_child()

static void essential_thread_from_user_child ( void p1,
void p2,
void p3 
)
static

◆ essential_thread_from_user_extra()

static void essential_thread_from_user_extra ( void p1,
void p2,
void p3 
)
static

◆ from_user_invalid_stacksize_child()

static void from_user_invalid_stacksize_child ( void p1,
void p2,
void p3 
)
static

◆ from_user_invalid_stacksize_extra()

static void from_user_invalid_stacksize_extra ( void p1,
void p2,
void p3 
)
static

◆ from_user_no_access_stack_child_entry()

static void from_user_no_access_stack_child_entry ( void p1,
void p2,
void p3 
)
static

◆ from_user_no_access_stack_extra_entry()

static void from_user_no_access_stack_extra_entry ( void p1,
void p2,
void p3 
)
static

◆ grant_access_kobj_invalid_child()

static void grant_access_kobj_invalid_child ( void p1,
void p2,
void p3 
)
static

◆ higher_prio_from_user_child()

static void higher_prio_from_user_child ( void p1,
void p2,
void p3 
)
static

◆ higher_prio_from_user_extra()

static void higher_prio_from_user_extra ( void p1,
void p2,
void p3 
)
static

◆ invalid_prio_from_user_child()

static void invalid_prio_from_user_child ( void p1,
void p2,
void p3 
)
static

◆ invalid_prio_from_user_extra()

static void invalid_prio_from_user_extra ( void p1,
void p2,
void p3 
)
static

◆ K_MUTEX_DEFINE()

K_MUTEX_DEFINE ( kobject_mutex  )

◆ K_SEM_DEFINE() [1/2]

K_SEM_DEFINE ( kobject_public_sem  ,
(0)  ,
(10)   
)

◆ K_SEM_DEFINE() [2/2]

K_SEM_DEFINE ( kobject_sem  ,
(0)  ,
(10)   
)

◆ K_THREAD_STACK_DEFINE() [1/2]

K_THREAD_STACK_DEFINE ( child_stack  ,
(512+CONFIG_TEST_EXTRA_STACKSIZE)   
)

◆ K_THREAD_STACK_DEFINE() [2/2]

K_THREAD_STACK_DEFINE ( extra_stack  ,
(512+CONFIG_TEST_EXTRA_STACKSIZE)   
)

◆ kobject_access_grant_user_part()

static void kobject_access_grant_user_part ( void p1,
void p2,
void p3 
)
static

◆ kobject_grant_access_child_entry()

static void kobject_grant_access_child_entry ( void p1,
void p2,
void p3 
)
static

◆ kobject_grant_access_extra_entry()

static void kobject_grant_access_extra_entry ( void p1,
void p2,
void p3 
)
static

◆ kobject_revoke_access_user_part()

static void kobject_revoke_access_user_part ( void p1,
void p2,
void p3 
)
static

◆ new_thrd_from_user_with_in_use_stack()

static void new_thrd_from_user_with_in_use_stack ( void p1,
void p2,
void p3 
)
static

◆ new_thread_from_user_child()

static void new_thread_from_user_child ( void p1,
void p2,
void p3 
)
static

◆ new_thread_from_user_extra()

static void new_thread_from_user_extra ( void p1,
void p2,
void p3 
)
static

◆ new_user_thrd_child_with_in_use_stack()

static void new_user_thrd_child_with_in_use_stack ( void p1,
void p2,
void p3 
)
static

◆ reinitialize_thread_kobj_child()

static void reinitialize_thread_kobj_child ( void p1,
void p2,
void p3 
)
static

◆ reinitialize_thread_kobj_extra()

static void reinitialize_thread_kobj_extra ( void p1,
void p2,
void p3 
)
static

◆ release_from_user_child()

static void release_from_user_child ( void p1,
void p2,
void p3 
)
static

◆ residual_permissions_child_fail()

static void residual_permissions_child_fail ( void p1,
void p2,
void p3 
)
static

◆ residual_permissions_child_success()

static void residual_permissions_child_success ( void p1,
void p2,
void p3 
)
static

◆ supervisor_from_user_child()

static void supervisor_from_user_child ( void p1,
void p2,
void p3 
)
static

◆ supervisor_from_user_extra()

static void supervisor_from_user_extra ( void p1,
void p2,
void p3 
)
static

◆ syscall_invalid_kobject_user_part()

static void syscall_invalid_kobject_user_part ( void p1,
void p2,
void p3 
)
static

◆ test_access_kobject_without_init_access()

void test_access_kobject_without_init_access ( void  )

Object validation checks without init access.

Test syscall on a kobject which is not initialized and has no access

◆ test_access_kobject_without_init_with_access()

void test_access_kobject_without_init_with_access ( void  )

Test syscall on a kobject which is not initialized and has access.

See also
k_thread_access_grant()

◆ test_alloc_kobjects()

void test_alloc_kobjects ( void  )

Test kernel object allocation.

Allocate all kinds of kernel object and do permission operation functions.

See also
k_object_alloc()

◆ test_create_new_essential_thread_from_user()

void test_create_new_essential_thread_from_user ( void  )

Create a new essential thread from user.

◆ test_create_new_higher_prio_thread_from_user()

void test_create_new_higher_prio_thread_from_user ( void  )

Thread creation with prority is higher than current thread.

_handler_k_thread_create validation.

◆ test_create_new_invalid_prio_thread_from_user()

void test_create_new_invalid_prio_thread_from_user ( void  )

Create a new thread whose prority is invalid.

_handler_k_thread_create validation.

◆ test_create_new_supervisor_thread_from_user()

void test_create_new_supervisor_thread_from_user ( void  )

Test to create a new supervisor thread from user.

The system kernel must prevent user threads from creating supervisor threads.

◆ test_create_new_thread_from_user()

void test_create_new_thread_from_user ( void  )

Test thread create from a user thread and check permissions.

  • Test user thread can create new thread.
  • Verify that given thread and thread stack permissions to the user thread, allow to create new user thread.
  • Veify that new created user thread have access to its own thread object by aborting itself.

◆ test_create_new_thread_from_user_huge_stacksize()

void test_create_new_thread_from_user_huge_stacksize ( void  )

Test to check stack overflow from user thread.

Create a new thread from user and use a stack bigger than allowed size. This is_handler_k_thread_create validation.

◆ test_create_new_thread_from_user_invalid_stacksize()

void test_create_new_thread_from_user_invalid_stacksize ( void  )

Test to validate user thread spawning with stack overflow.

Create a new thread from user and use a huge stack size which overflows. This is _handler_k_thread_create validation.

◆ test_create_new_thread_from_user_no_access_stack()

void test_create_new_thread_from_user_no_access_stack ( void  )

Test creates new thread from usermode without stack access.

Create a new thread from user and the user doesn't have access to the stack region of new thread. _handler_k_thread_create validation.

◆ test_kobj_create_out_of_memory()

void test_kobj_create_out_of_memory ( void  )

Test kernel object until out of memory.

Create a dynamic kernel object repeatedly until run out of all heap memory, an expected out of memory error generated.

See also
k_object_alloc()

◆ test_kobject_access_all_grant()

void test_kobject_access_all_grant ( void  )

Test supervisor thread grants kernel objects all access public status.

System makes kernel object kobject_public_sem public to all threads Test the access to that kernel object by creating two new user threads.

See also
k_object_access_all_grant()

◆ test_kobject_access_all_grant_error()

void test_kobject_access_all_grant_error ( void  )

Test grant access to all the kobject for thread.

Call function with a NULL parameter, an expected fault happened.

See also
k_thread_access_all_grant()

◆ test_kobject_access_grant()

void test_kobject_access_grant ( void  )

Test access to a invalid semaphore who's address is NULL.

See also
k_thread_access_grant(), k_thread_user_mode_enter()

◆ test_kobject_access_grant_error()

void test_kobject_access_grant_error ( void  )

Test grant access of given NULL kobject.

Call function with a NULL parameter in supervisor mode, nothing happened.

See also
k_thread_access_grant()

◆ test_kobject_access_grant_error_user()

void test_kobject_access_grant_error_user ( void  )

Test grant access of given NULL thread in usermode.

Call function with NULL parameter, an expected fault happened.

See also
k_thread_access_grant()

◆ test_kobject_access_grant_error_user_null()

void test_kobject_access_grant_error_user_null ( void  )

Test grant access of given NULL kobject in usermode.

Call function with a NULL parameter, an expected fault happened.

See also
k_thread_access_grant()

◆ test_kobject_access_grant_to_invalid_thread()

void test_kobject_access_grant_to_invalid_thread ( void  )

Test grant access to a valid kobject but invalid thread id.

See also
k_object_access_grant(), k_object_access_revoke(), z_object_find()

◆ test_kobject_access_invalid_kobject()

void test_kobject_access_invalid_kobject ( void  )

Object validation checks.

Test syscall on a kobject which is not present in the hash table.

◆ test_kobject_free_error()

void test_kobject_free_error ( void  )

Test free an invalid kernel object.

Spawn a thread free a NULL, an expected fault happened.

See also
k_object_free()

◆ test_kobject_grant_access_kobj()

void test_kobject_grant_access_kobj ( void  )

Test access revoke.

See also
k_thread_access_grant(), k_object_access_revoke()

◆ test_kobject_grant_access_kobj_invalid()

void test_kobject_grant_access_kobj_invalid ( void  )

Test access grant between threads.

Test access grant to thread B from thread A which doesn't have required permissions.

See also
k_thread_access_grant()

◆ test_kobject_init_error()

void test_kobject_init_error ( void  )

Test alloc an invalid kernel object.

Allocate invalid kernel objects, then no alloction will be returned.

See also
k_object_alloc()

◆ test_kobject_perm_error()

void test_kobject_perm_error ( void  )

Test grant access failed in user mode.

Before grant access of static kobject to user thread, any grant access to this thread, will trigger an expected thread permission error.

See also
k_thread_access_grant()

◆ test_kobject_reinitialize_thread_kobj()

void test_kobject_reinitialize_thread_kobj ( void  )

Test to reinitialize the k_thread object.

◆ test_kobject_release_from_user()

void test_kobject_release_from_user ( void  )

Test revoke permission of a k_object from userspace.

See also
k_thread_access_grant(), k_object_release()

◆ test_kobject_release_null()

void test_kobject_release_null ( void  )

◆ test_kobject_revoke_access()

void test_kobject_revoke_access ( void  )

Test access revoke.

See also
k_thread_access_grant(), k_object_access_revoke()

◆ test_mark_thread_exit_uninitialized()

void test_mark_thread_exit_uninitialized ( void  )

Test when thread exits, kernel marks stack objects uninitialized.

When thread exits, the kernel upon thread exit, should mark the exiting thread and thread stack object as uninitialized

◆ test_new_user_thread_with_in_use_stack_obj()

void test_new_user_thread_with_in_use_stack_obj ( void  )

Test create new user thread from a user thread with in-use stack obj.

The kernel must prevent new user threads to use initiliazed (in-use) stack objects. In that case extra_thread is going to be create with in-use stack object child_stack. That will generate error, showing that kernel memory protection is working correctly.

◆ test_syscall_invalid_kobject()

void test_syscall_invalid_kobject ( void  )

Test syscall can take a different type of kobject.

Test syscall can take a different type of kobject and syscall will generate fatal error if check fails.

See also
k_thread_access_grant()

◆ test_thread_alloc_out_of_idx()

void test_thread_alloc_out_of_idx ( void  )

◆ test_thread_has_residual_permissions()

void test_thread_has_residual_permissions ( void  )

Test access permission of a terminated thread.

If a deleted thread with some permissions is recreated with the same tid, check if it still has the permissions.

See also
k_thread_access_grant()

◆ test_thread_without_kobject_permission()

void test_thread_without_kobject_permission ( void  )

Test user thread can access a k_object without grant.

The kernel will fail system call on kernel object that tracks thread permissions, on thread that don't have permission granted on the object.

See also
k_thread_access_grant(), k_thread_user_mode_enter()

◆ thread_stack_init_objects()

static void thread_stack_init_objects ( void p1,
void p2,
void p3 
)
static

◆ thread_without_kobject_permission_user_part()

static void thread_without_kobject_permission_user_part ( void p1,
void p2,
void p3 
)
static

◆ tThread_object_free_error()

static void tThread_object_free_error ( void p1,
void p2,
void p3 
)
static

◆ user_huge_stacksize_child()

static void user_huge_stacksize_child ( void p1,
void p2,
void p3 
)
static

◆ user_huge_stacksize_extra()

static void user_huge_stacksize_extra ( void p1,
void p2,
void p3 
)
static

◆ without_init_with_access_child()

static void without_init_with_access_child ( void p1,
void p2,
void p3 
)
static

Variable Documentation

◆ c

struct k_condvar c

◆ child_thread

struct k_thread child_thread

◆ extra_thread

struct k_thread extra_thread

◆ f

struct k_futex f

◆ kobject_sem_no_init_access

struct k_sem kobject_sem_no_init_access

◆ kobject_sem_no_init_no_access

struct k_sem kobject_sem_no_init_no_access

◆ kobject_sem_not_hash_table

struct k_sem kobject_sem_not_hash_table

◆ mq

struct k_msgq mq

◆ ms

struct k_mem_slab ms

◆ mutex

struct k_mutex mutex

◆ p

struct k_pipe p

◆ ps

struct k_poll_signal ps

◆ q

struct k_queue q

◆ random_sem_type

struct k_sem* random_sem_type

◆ s

struct k_stack s

◆ sem

struct k_sem sem

◆ t

struct k_thread t

◆ timer

struct k_timer timer

◆ zs

struct z_thread_stack_element zs