### 5.2.1 Mitigations for out-of-bound memory access
This section is a list of technical requirements necessary to satisfy the CRA essential requirements. Each technical requirement can be satisfied by one or more potential mitigations. Each mitigation may or may not be appropriate for an individual use case. The following section will define which mitigations will be required, depending on a risk factor, the overall risk tolerance, and/or a use case in the following section.
FIXME link to risk factors/use cases
### 5.2.2 **TR-OOBM**: Mitigations for out-of-bounds memory access
Kernel stack exhaustion detection
#### 5.2.2.1 Threat description
* Threat: kernel stack exhaustion causes thread to write beyond end of stack
* Mitigation: kernel stack limits validated
Threat: attacker uses an operating systems vulnerability to access memory in an unauthorized manner.
*Threat: uninitialized kernel stack memory controlled by attacker
*Sub-threat: uninitialized kernel stack memory controlled by attacker
* Mitigation: zero-initialize all kernel stack memory before use
* Test: sequentially call 2 functions that allocate the same amount of memory, fill the first with known values and return, and during second function call, read the stack contents back
* Result: stack contents are clear on second call
* Output: action logged as an event
* Requirements: way to read log output on product as shipped
*Threat: uninitialized kernel heap memory controlled by attacker
*Sub-threat: uninitialized kernel heap memory controlled by attacker
* Mitigation: zero-initialize all kernel heap memory before use
* Test: allocate heap memory, fill with a known value, free it, allocate it again in a deterministic way to get the same heap region, and read back the contents
* Result: heap contents are clear on second allocation
* Output: action logged as an event
* Requirements: way to read log output on product as shipped
Kernel linked list protection
#### 5.2.2. **MI-KLLP**: Kernel linked list protection
*Threat: kernel doubly linked list corruption
*Sub-threat: kernel doubly linked list corruption
* Mitigation: linked list implementation checks prev/next pointers on add/del
* Test: add or delete an item to an uninitialized list
* Result: thread is killed
* Output: action logged as an event or the OS reboots
* Requirements: way to read log output on product as shipped
Prevent execution of non-kernel code memory
#### 5.2.2. **MI-KPXM**: Prevent execution of non-kernel code memory
*Threat: Non-code executable kernel memory
*Sub-threat: Non-code executable kernel memory
* Mitigation: Only kernel code memory regions are executable
* Test: copy a trivial return-only function into every class of non-code memory in the kernel (e.g. stack, heap, read-only data), one to a thread, and attempt to execute each one
* Result: each thread is killed
* Output: action logged as an event or the OS reboots
* Requirements: way to read log output on product as shipped
Prevent writes to kernel code and read-only data memory
#### 5.2.2. **MI-KPWM**: Prevent writes to kernel code and read-only data memory
*Threat: Writable kernel code or read-only memory
*Sub-threat: Writable kernel code or read-only memory
* Mitigation: All kernel code memory and non-writable data is read-only
* Test: from separate threads, write to each portion of kernel code
and non-writable data region
@@ -987,27 +991,27 @@ Prevent writes to kernel code and read-only data memory
* Output: action logged as an event or the OS reboots
* Requirements: way to read log output on product as shipped
Prevent unintentional kernel access to unprivileged memory
#### 5.2.2. **MI-KPUM**: Prevent unintentional kernel access to unprivileged memory
*Threat: Unexpected access to userspace memory from OS kernel
*Sub-threat: Unexpected access to userspace memory from OS kernel
* Test: in separate kernel threads, read, write, and execute memory regions that are mapped to userspace without going through dedicated userspace memory access routines
* Result: each thread killed
* Output: action logged as an event or the OS reboots
* Requirements: way to read log output on product as shipped
> **TODO**: Connect the technical security requirements in Section 5.2 to specific Risk Factors, and define these as sets of Risk Mitigations that will be referenced in section 6.