Skip to content

Commit

Permalink
assert: generate oops if invoked from usermode
Browse files Browse the repository at this point in the history
User mode isn't allowed to generate a panic and this would
lead to a confusing privilege violation exception.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
  • Loading branch information
Andrew Boie authored and nashif committed Jul 20, 2019
1 parent 2d9032e commit 39425ea
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/os/assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit 39425ea

Please sign in to comment.