You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/12/15 14:15:33 UTC

[GitHub] [incubator-nuttx] anchao opened a new pull request #5007: arch/assert: flush the syslog before stack dump to avoid buffer overwrite

anchao opened a new pull request #5007:
URL: https://github.com/apache/incubator-nuttx/pull/5007


   ## Summary
   
   arch/assert: flush the syslog before stack dump
   
   flush the syslog before stack dump to avoid buffer overwrite
   
   ## Impact
   
   dump printf
   
   ## Testing
   
   Trigger crash and check the dump info


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #5007: arch/assert: flush the syslog before stack dump to avoid buffer overwrite

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #5007:
URL: https://github.com/apache/incubator-nuttx/pull/5007


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5007: arch/assert: flush the syslog before stack dump to avoid buffer overwrite

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5007:
URL: https://github.com/apache/incubator-nuttx/pull/5007#discussion_r769685666



##########
File path: arch/avr/src/avr/up_dumpstate.c
##########
@@ -51,7 +52,11 @@ static void up_stackdump(uint16_t sp, uint16_t stack_top)
 {
   uint16_t stack;
 
-  for (stack = sp & ~3; stack < (stack_top & ~0x1f); stack += 12)
+  /* Flush any buffered SYSLOG data to avoid overwrite */
+
+  syslog_flush();
+
+  for (stack = sp & ~3; stack < (stack_top & ~0x3); stack += 12)

Review comment:
       ```suggestion
     for (stack = sp & ~0x3; stack < (stack_top & ~0x3); stack += 12)
   ```
   Just to keep same style as in other files




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5007: arch/assert: flush the syslog before stack dump to avoid buffer overwrite

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5007:
URL: https://github.com/apache/incubator-nuttx/pull/5007#discussion_r769678090



##########
File path: arch/z16/src/common/z16_stackdump.c
##########
@@ -68,8 +69,12 @@ static void z16_stackdump(void)
       stack = stack_base;
     }
 
+  /* Flush any buffered SYSLOG data to avoid overwrite */
+
+  syslog_flush();
+
   for (stack = stack & ~0x0f;
-       stack < stack_base + stack_size;
+       stack < ((stack_base + stack_size) & ~0x1f);

Review comment:
       ```suggestion
          stack < ((stack_base + stack_size) & ~0x0f);
   ```
   or for better compatibility:
   ```
     for (stack = stack & ~(8 * sizeof(chipreg_t) - 1);
          stack < ((stack_base + stack_size) & ~(8 * sizeof(chipreg_t) - 1));
          stack += 8 * sizeof(chipreg_t))
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao commented on a change in pull request #5007: arch/assert: flush the syslog before stack dump to avoid buffer overwrite

Posted by GitBox <gi...@apache.org>.
anchao commented on a change in pull request #5007:
URL: https://github.com/apache/incubator-nuttx/pull/5007#discussion_r769684413



##########
File path: arch/z16/src/common/z16_stackdump.c
##########
@@ -68,8 +69,12 @@ static void z16_stackdump(void)
       stack = stack_base;
     }
 
+  /* Flush any buffered SYSLOG data to avoid overwrite */
+
+  syslog_flush();
+
   for (stack = stack & ~0x0f;
-       stack < stack_base + stack_size;
+       stack < ((stack_base + stack_size) & ~0x1f);

Review comment:
       Done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5007: arch/assert: flush the syslog before stack dump to avoid buffer overwrite

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5007:
URL: https://github.com/apache/incubator-nuttx/pull/5007#discussion_r769677794



##########
File path: arch/z16/src/common/z16_stackdump.c
##########
@@ -68,8 +69,12 @@ static void z16_stackdump(void)
       stack = stack_base;
     }
 
+  /* Flush any buffered SYSLOG data to avoid overwrite */
+
+  syslog_flush();
+
   for (stack = stack & ~0x0f;
-       stack < stack_base + stack_size;
+       stack < ((stack_base + stack_size) & ~0x1f);

Review comment:
       ```suggestion
          stack < ((stack_base + stack_size) & ~0x0f);
   ```
   or for better compatibility:
   ```
     for (stack = stack & ~(8 * sizeof(chipreg_t) - 1);
          stack < ((stack_base + stack_size) & ~(8 * sizeof(chipreg_t) - 1));
          stack += 8 * sizeof(chipreg_t))
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5007: arch/assert: flush the syslog before stack dump to avoid buffer overwrite

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5007:
URL: https://github.com/apache/incubator-nuttx/pull/5007#discussion_r769680901



##########
File path: arch/z16/src/common/z16_stackdump.c
##########
@@ -68,8 +69,12 @@ static void z16_stackdump(void)
       stack = stack_base;
     }
 
+  /* Flush any buffered SYSLOG data to avoid overwrite */
+
+  syslog_flush();
+
   for (stack = stack & ~0x0f;
-       stack < stack_base + stack_size;
+       stack < ((stack_base + stack_size) & ~0x1f);

Review comment:
       Or I'm missing something because `arch/avr/src/avr/up_dumpstate.c` contain `for (stack = sp & ~3; stack < (stack_top & ~0x1f); stack += 12)`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org