mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
checkstack: fix access overflow when checkstack
We should check length first, and then check the value Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
3c6cb0b76e
commit
113bb02568
11 changed files with 11 additions and 11 deletions
|
|
@ -119,7 +119,7 @@ size_t arm_stack_check(void *stackbase, size_t nbytes)
|
|||
*/
|
||||
|
||||
for (ptr = (uint32_t *)start, mark = (nbytes >> 2);
|
||||
*ptr == STACK_COLOR && mark > 0;
|
||||
mark > 0 && *ptr == STACK_COLOR;
|
||||
ptr++, mark--);
|
||||
|
||||
/* If the stack is completely used, then this might mean that the stack
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ size_t arm64_stack_check(void *stackbase, size_t nbytes)
|
|||
*/
|
||||
|
||||
for (ptr = (uint32_t *)start, mark = (nbytes >> 2);
|
||||
*ptr == STACK_COLOR && mark > 0;
|
||||
mark > 0 && *ptr == STACK_COLOR;
|
||||
ptr++, mark--);
|
||||
|
||||
/* If the stack is completely used, then this might mean that the stack
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ size_t avr_stack_check(uintptr_t alloc, size_t size)
|
|||
*/
|
||||
|
||||
for (ptr = (FAR uint8_t *)alloc, mark = size;
|
||||
*ptr == STACK_COLOR && mark > 0;
|
||||
mark > 0 && *ptr == STACK_COLOR;
|
||||
ptr++, mark--);
|
||||
|
||||
/* If the stack is completely used, then this might mean that the stack
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ size_t ceva_stack_check(uintptr_t alloc, size_t size)
|
|||
*/
|
||||
|
||||
for (ptr = (uint32_t *)alloc, mark = nwords;
|
||||
*ptr == STACK_COLOR && mark > 0;
|
||||
mark > 0 && *ptr == STACK_COLOR;
|
||||
ptr++, mark--);
|
||||
|
||||
/* If the stack is completely used, then this might mean that the stack
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ size_t or1k_stack_check(uintptr_t alloc, size_t size)
|
|||
size = end - start;
|
||||
|
||||
for (ptr = (uint32_t *)start, mark = (size >> 2);
|
||||
*ptr == STACK_COLOR && mark > 0;
|
||||
mark > 0 && *ptr == STACK_COLOR;
|
||||
ptr++, mark--);
|
||||
|
||||
/* Return our guess about how much stack space was used */
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ size_t riscv_stack_check(uintptr_t alloc, size_t size)
|
|||
*/
|
||||
|
||||
for (ptr = (uint32_t *)start, mark = (size >> 2);
|
||||
*ptr == STACK_COLOR && mark > 0;
|
||||
mark > 0 && *ptr == STACK_COLOR;
|
||||
ptr++, mark--);
|
||||
|
||||
/* If the stack is completely used, then this might mean that the stack
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ size_t sim_stack_check(void *alloc, size_t size)
|
|||
*/
|
||||
|
||||
for (ptr = (uint32_t *)start, mark = (size >> 2);
|
||||
*ptr == STACK_COLOR && mark > 0;
|
||||
mark > 0 && *ptr == STACK_COLOR;
|
||||
ptr++, mark--);
|
||||
|
||||
/* If the stack is completely used, then this might mean that the stack
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ size_t sparc_stack_check(void *stackbase, size_t nbytes)
|
|||
*/
|
||||
|
||||
for (ptr = (uint32_t *)start, mark = (nbytes >> 2);
|
||||
*ptr == STACK_COLOR && mark > 0;
|
||||
mark > 0 && *ptr == STACK_COLOR;
|
||||
ptr++, mark--);
|
||||
|
||||
/* If the stack is completely used, then this might mean that the stack
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ size_t tricore_stack_check(uintptr_t alloc, size_t size)
|
|||
*/
|
||||
|
||||
for (ptr = (uint32_t *)start, mark = (size >> 2);
|
||||
*ptr == STACK_COLOR && mark > 0;
|
||||
mark > 0 && *ptr == STACK_COLOR;
|
||||
ptr++, mark--);
|
||||
|
||||
/* Return our guess about how much stack space was used */
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ size_t x86_64_stack_check(void *stackbase, size_t nbytes)
|
|||
*/
|
||||
|
||||
for (ptr = (uint32_t *)start, mark = (nbytes >> 2);
|
||||
*ptr == STACK_COLOR && mark > 0;
|
||||
mark > 0 && *ptr == STACK_COLOR;
|
||||
ptr++, mark--);
|
||||
|
||||
/* Return our guess about how much stack space was used */
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ size_t xtensa_stack_check(uintptr_t alloc, size_t size)
|
|||
*/
|
||||
|
||||
for (ptr = (uint32_t *)start, mark = (size >> 2);
|
||||
*ptr == STACK_COLOR && mark > 0;
|
||||
mark > 0 && *ptr == STACK_COLOR;
|
||||
ptr++, mark--);
|
||||
|
||||
/* If the stack is completely used, then this might mean that the stack
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue