From 39425eaada193d2de1f4650b5eacea1cead7c6c7 Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Thu, 18 Jul 2019 14:23:40 -0700 Subject: [PATCH] assert: generate oops if invoked from usermode User mode isn't allowed to generate a panic and this would lead to a confusing privilege violation exception. Signed-off-by: Andrew Boie --- lib/os/assert.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/os/assert.c b/lib/os/assert.c index d55e6f098cf..51ffaba8ddd 100644 --- a/lib/os/assert.c +++ b/lib/os/assert.c @@ -24,8 +24,17 @@ */ __weak void assert_post_action(const char *file, unsigned int line) { - ARG_UNUSED(file); - ARG_UNUSED(line); + ARG_UNUSED(file); + ARG_UNUSED(line); - k_panic(); +#ifdef CONFIG_USERSPACE + /* User threads aren't allowed to induce kernel panics; generate + * an oops instead. + */ + if (_is_user_context()) { + k_oops(); + } +#endif + + k_panic(); }