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 2020/10/12 16:01:25 UTC

[GitHub] [incubator-nuttx] davids5 commented on a change in pull request #1900: ARM stack fix: Same boundary calculation in do_stackcheck and stack_color.

davids5 commented on a change in pull request #1900:
URL: https://github.com/apache/incubator-nuttx/pull/1900#discussion_r503387000



##########
File path: arch/arm/src/common/arm_checkstack.c
##########
@@ -55,17 +55,31 @@
 
 #ifdef CONFIG_STACK_COLORATION
 
+/****************************************************************************
+ * Pre-processor Macros
+ ****************************************************************************/
+
+/* 32bit alignment macros */
+
+#define INT32_ALIGN_MASK    (3)

Review comment:
       Can these live in a common file?

##########
File path: arch/arm/src/common/arm_checkstack.c
##########
@@ -78,34 +92,34 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size);
  *
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size)
+static size_t do_stackcheck(FAR void *stackbase, size_t nbytes)
 {
-  FAR uintptr_t start;
-  FAR uintptr_t end;
+  uintptr_t start;
+  uintptr_t end;
   FAR uint32_t *ptr;
   size_t mark;
 
-  if (size == 0)
+  if (nbytes == 0)
     {
       return 0;
     }
 
-  /* Get aligned addresses of the top and bottom of the stack */
+  /* Take extra care that we do not check outside the stack boundaries */
 
-  start = alloc & ~3;
-  end   = (alloc + size + 3) & ~3;
+  start = INT32_ALIGN_UP((uintptr_t)stackbase);

Review comment:
       As discussed this has the potential masking tcb corruption. I feel it would be better to know that. But I will not insist on making it a condition on bring in the PR. 




----------------------------------------------------------------
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.

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