mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 13:13:08 +08:00
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:
+22
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user