tests: coredump: use undefined instruction to trigger CPU fault
When building the test for Cortex-M, use an undefined instruction to trigger a CPU fault, instead of null pointer de-referencing. That's because null-pointer access may, in TrustZone-enabled platforms, lead to a system crash (due to security violation). Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
98d691e223
commit
633a7208df
1 changed files with 9 additions and 0 deletions
|
@ -9,8 +9,17 @@
|
|||
|
||||
void func_3(uint32_t *addr)
|
||||
{
|
||||
#if !defined(CONFIG_CPU_CORTEX_M)
|
||||
/* For null pointer reference */
|
||||
*addr = 0;
|
||||
#else
|
||||
ARG_UNUSED(addr);
|
||||
/* Dereferencing null-pointer in TrustZone-enabled
|
||||
* builds may crash the system, so use, instead an
|
||||
* undefined instruction to trigger a CPU fault.
|
||||
*/
|
||||
__asm__ volatile("udf #0" : : : );
|
||||
#endif
|
||||
}
|
||||
|
||||
void func_2(uint32_t *addr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue