tests: z_except_reason() policy from usermode
User mode should be able to successfully induce a kernel oops, or stack check fail fatal error. The latter is required by compiler stack canaries. User mode should not be able to induce a kernel panic, or fake some other kind of exception. Currently supported on ARM and x86 platforms. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
34ffda3d23
commit
55fce980d7
1 changed files with 38 additions and 0 deletions
|
@ -1119,6 +1119,37 @@ void test_object_recycle(void)
|
|||
zassert_true(perms_count == 1, "invalid number of thread permissions");
|
||||
}
|
||||
|
||||
#define test_oops(provided, expected) do { \
|
||||
expect_fault = true; \
|
||||
expected_reason = expected; \
|
||||
z_except_reason(provided); \
|
||||
} while (false)
|
||||
|
||||
void test_oops_panic(void)
|
||||
{
|
||||
test_oops(K_ERR_KERNEL_PANIC, K_ERR_KERNEL_OOPS);
|
||||
}
|
||||
|
||||
void test_oops_oops(void)
|
||||
{
|
||||
test_oops(K_ERR_KERNEL_OOPS, K_ERR_KERNEL_OOPS);
|
||||
}
|
||||
|
||||
void test_oops_exception(void)
|
||||
{
|
||||
test_oops(K_ERR_CPU_EXCEPTION, K_ERR_KERNEL_OOPS);
|
||||
}
|
||||
|
||||
void test_oops_maxint(void)
|
||||
{
|
||||
test_oops(INT_MAX, K_ERR_KERNEL_OOPS);
|
||||
}
|
||||
|
||||
void test_oops_stackcheck(void)
|
||||
{
|
||||
test_oops(K_ERR_STACK_CHK_FAIL, K_ERR_STACK_CHK_FAIL);
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
struct k_mem_partition *parts[] = {&part0, &part1,
|
||||
|
@ -1171,6 +1202,13 @@ void test_main(void)
|
|||
ztest_unit_test(test_stack_buffer),
|
||||
ztest_user_unit_test(test_unimplemented_syscall),
|
||||
ztest_user_unit_test(test_bad_syscall),
|
||||
#if !defined(CONFIG_ARC) /* FIXME: #17590 */
|
||||
ztest_user_unit_test(test_oops_panic),
|
||||
ztest_user_unit_test(test_oops_oops),
|
||||
ztest_user_unit_test(test_oops_exception),
|
||||
ztest_user_unit_test(test_oops_maxint),
|
||||
ztest_user_unit_test(test_oops_stackcheck),
|
||||
#endif /* !defined(CONFIG_ARC) */
|
||||
ztest_unit_test(test_object_recycle)
|
||||
);
|
||||
ztest_run_test_suite(userspace);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue