sched/assert: Re-implement assert() into user space

_assert is a kernel procedure, entered via system call to make the core
dump in privileged mode.

Running exit() from this context is not OK as it runs the registered
exit functions and flushes streams, which must not be done
from privileged mode as it is a security hole.

Thus, implement assert() into user space (again) and remove the exit()
call from the kernel procedure.
This commit is contained in:
Ville Juven
2022-12-22 12:21:56 +02:00
committed by Xiang Xiao
parent b0b352f784
commit 172b209f2d
5 changed files with 63 additions and 5 deletions
+22 -3
View File
@@ -43,9 +43,9 @@
#undef DEBUGVERIFY /* Like VERIFY, but only if CONFIG_DEBUG_ASSERTIONS is defined */
#ifdef CONFIG_HAVE_FILENAME
# define PANIC() _assert(__FILE__, __LINE__)
# define PANIC() __assert(__FILE__, __LINE__)
#else
# define PANIC() _assert("unknown", 0)
# define PANIC() __assert("unknown", 0)
#endif
#define ASSERT(f) do { if (!(f)) PANIC(); } while (0)
@@ -106,7 +106,26 @@ extern "C"
* Public Function Prototypes
****************************************************************************/
void _assert(FAR const char *filename, int linenum) noreturn_function;
/****************************************************************************
* Name: _assert
*
* Description:
* This is the assert system call that performs the core dump etc. Function
* might not return if it is not safe to do so (in IRQ or in IDLE task).
*
****************************************************************************/
void _assert(FAR const char *filename, int linenum);
/****************************************************************************
* Name: __assert
*
* Description:
* This is the user space assert procedure.
*
****************************************************************************/
void __assert(FAR const char *filename, int linenum) noreturn_function;
#undef EXTERN
#ifdef __cplusplus