From a7a3e800bf2fa588695b189c1bf4b39dde2a47af Mon Sep 17 00:00:00 2001 From: Carlo Caione Date: Thu, 19 Nov 2020 12:27:48 +0100 Subject: [PATCH] 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 --- arch/arm/core/aarch64/fatal.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/core/aarch64/fatal.c b/arch/arm/core/aarch64/fatal.c index ab78fcd911d..674de6842f1 100644 --- a/arch/arm/core/aarch64/fatal.c +++ b/arch/arm/core/aarch64/fatal.c @@ -235,6 +235,17 @@ void z_arm64_do_kernel_oops(z_arch_esf_t *esf) /* x8 holds the exception reason */ unsigned int reason = esf->x8; +#if defined(CONFIG_USERSPACE) + /* + * User mode is only allowed to induce oopses and stack check + * failures via software-triggered system fatal exceptions. + */ + if (((_current->base.user_options & K_USER) != 0) && + reason != K_ERR_STACK_CHK_FAIL) { + reason = K_ERR_KERNEL_OOPS; + } +#endif + z_arm64_fatal_error(reason, esf); }