arch/assert: flush the syslog before stack dump

flush the syslog before stack dump to avoid buffer overwrite

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an
2021-12-15 19:40:52 +08:00
committed by Xiang Xiao
parent ed1e4ddfa7
commit b11833cbba
22 changed files with 107 additions and 8 deletions
+6 -1
View File
@@ -29,6 +29,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/syslog/syslog.h>
#include "up_arch.h"
#include "up_internal.h"
@@ -67,7 +68,11 @@ static void m16c_stackdump(uint16_t sp, uint16_t stack_top)
{
uint16_t stack;
for (stack = sp & ~7; stack < stack_top; stack += 8)
/* Flush any buffered SYSLOG data to avoid overwrite */
syslog_flush();
for (stack = sp & ~7; stack < (stack_top & ~7); stack += 8)
{
uint8_t *ptr = (uint8_t *)stack;
_alert("%04x: %02x %02x %02x %02x %02x %02x %02x %02x\n",
+6 -1
View File
@@ -30,6 +30,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/syslog/syslog.h>
#include "up_arch.h"
#include "up_internal.h"
@@ -69,7 +70,11 @@ static void rx65n_stackdump(uint16_t sp, uint16_t stack_top)
{
uint16_t stack;
for (stack = sp & ~7; stack < stack_top; stack += 8) /* check */
/* Flush any buffered SYSLOG data to avoid overwrite */
syslog_flush();
for (stack = sp & ~7; stack < (stack_top & ~7); stack += 8) /* check */
{
uint8_t *ptr = (uint8_t *)&stack;
+6 -1
View File
@@ -29,6 +29,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/syslog/syslog.h>
#include "up_arch.h"
#include "up_internal.h"
@@ -54,7 +55,11 @@ static void sh1_stackdump(uint32_t sp, uint32_t stack_top)
{
uint32_t stack;
for (stack = sp & ~0x1f; stack < stack_top; stack += 32)
/* Flush any buffered SYSLOG data to avoid overwrite */
syslog_flush();
for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32)
{
uint32_t *ptr = (uint32_t *)stack;
_alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",