zephyr/tests/kernel/mem_protect/protection
Yong Cong Sin e54b27b967 arch: define struct arch_esf and deprecate z_arch_esf_t
Make `struct arch_esf` compulsory for all architectures by
declaring it in the `arch_interface.h` header.

After this commit, the named struct `z_arch_esf_t` is only used
internally to generate offsets, and is slated to be removed
from the `arch_interface.h` header in the future.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-04 14:02:51 -05:00
..
src arch: define struct arch_esf and deprecate z_arch_esf_t 2024-06-04 14:02:51 -05:00
CMakeLists.txt cmake: increase minimal required version to 3.20.0 2021-08-20 09:47:34 +02:00
prj.conf tests: remove CONFIG_ZTEST_NEW_API in all tests 2023-10-20 15:04:29 +02:00
README.rst tests: mem_protect: fix README and adapt for cmake 2018-01-11 12:50:14 -05:00
testcase.yaml tests: userspace: exclude ucans32k1sic due to lack of MPU regions 2023-12-05 16:20:10 -06:00

.. _protection_tests:

Protection tests
#################################

Overview
********
This test case verifies that protection is provided
against the following security issues:

* Write to read-only data.
* Write to text.
* Execute from data.
* Execute from stack.
* Execute from heap.

Building and Running
********************

This project can be built and executed as follows:


.. zephyr-app-commands::
   :zephyr-app: tests/kernel/mem_protect/protection
   :board: <board name>
   :goals: run
   :compact:

Connect the board to your host computer using the USB port.
Flash the generated zephyr.bin on the board.
Reset the board.

Sample Output
=============

.. code-block:: console

   ***** BOOTING ZEPHYR OS v1.8.99 - BUILD: Jun 19 2017 12:44:27 *****
   Running test suite test_protection
   tc_start() - write_ro
   trying to write to rodata at 0x00003124
   ***** BUS FAULT *****
     Executing thread ID (thread): 0x200001bc
     Faulting instruction address:  0x88c
     Imprecise data bus error
   Caught system error -- reason 0
   ===================================================================
   PASS - write_ro.
   tc_start() - write_text
   trying to write to text at 0x000006c0
   ***** BUS FAULT *****
     Executing thread ID (thread): 0x200001bc
     Faulting instruction address:  0xd60
     Imprecise data bus error
   Caught system error -- reason 0
   ===================================================================
   PASS - write_text.
   tc_start() - exec_data
   trying to call code written to 0x2000041d
   ***** BUS FAULT *****
     Executing thread ID (thread): 0x200001bc
     Faulting instruction address:  0x2000041c
     Imprecise data bus error
   Caught system error -- reason 0
   ===================================================================
   PASS - exec_data.
   tc_start() - exec_stack
   trying to call code written to 0x20000929
   ***** BUS FAULT *****
     Executing thread ID (thread): 0x200001bc
     Faulting instruction address:  0x20000928
     Imprecise data bus error
   Caught system error -- reason 0
   ===================================================================
   PASS - exec_stack.
   tc_start() - exec_heap
   trying to call code written to 0x20000455
   ***** BUS FAULT *****
     Executing thread ID (thread): 0x200001bc
     Faulting instruction address:  0x20000454
     Imprecise data bus error
   Caught system error -- reason 0
   ===================================================================
   PASS - exec_heap.
   ===================================================================
   PROJECT EXECUTION SUCCESSFUL