Skip to content

Commit a7a3e80

Browse files
carlocaionenashif
authored andcommitted
aarch64: fatal: Restrict oops-es when in user-mode
User mode is only allowed to induce oopses and stack check failures via software-triggered system fatal exceptions. Signed-off-by: Carlo Caione <[email protected]>
1 parent 6978160 commit a7a3e80

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

arch/arm/core/aarch64/fatal.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,17 @@ void z_arm64_do_kernel_oops(z_arch_esf_t *esf)
235235
/* x8 holds the exception reason */
236236
unsigned int reason = esf->x8;
237237

238+
#if defined(CONFIG_USERSPACE)
239+
/*
240+
* User mode is only allowed to induce oopses and stack check
241+
* failures via software-triggered system fatal exceptions.
242+
*/
243+
if (((_current->base.user_options & K_USER) != 0) &&
244+
reason != K_ERR_STACK_CHK_FAIL) {
245+
reason = K_ERR_KERNEL_OOPS;
246+
}
247+
#endif
248+
238249
z_arm64_fatal_error(reason, esf);
239250
}
240251

0 commit comments

Comments
 (0)