From 86a412d65a52d51fa561b34fa9c70047a1656cb5 Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Mon, 18 May 2020 15:41:59 +0800 Subject: [PATCH] arch/stack: fix check stack breakage remove the TLS alignment check Regression by: -------------------------------------------------------- commit a6da3c2cb6a214b642fa09c48638f1442fdf9117 Author: Ouss4 Date: Thu May 7 18:50:07 2020 +0100 arch/*/*_checkstack.c: Get aligned address only when CONFIG_TLS_ALIGNED is enabled. -------------------------------------------------------- commit c2244a2382cf9c62937cc558cc947fae9f211b81 Author: Gregory Nutt Date: Thu May 7 09:46:47 2020 -0600 Remove CONFIG_TLS A first step in implementing the user-space error is force TLS to be enabled at all times. It is no longer optional Signed-off-by: chao.an --- arch/arm/src/common/arm_checkstack.c | 7 ++----- arch/or1k/src/common/up_checkstack.c | 7 ++----- arch/risc-v/src/common/riscv_checkstack.c | 7 ++----- arch/sim/src/sim/up_checkstack.c | 8 +++----- arch/xtensa/src/common/xtensa_checkstack.c | 12 ++++-------- 5 files changed, 13 insertions(+), 28 deletions(-) diff --git a/arch/arm/src/common/arm_checkstack.c b/arch/arm/src/common/arm_checkstack.c index ebdab95e91..61faad4d1b 100644 --- a/arch/arm/src/common/arm_checkstack.c +++ b/arch/arm/src/common/arm_checkstack.c @@ -92,22 +92,19 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) /* Get aligned addresses of the top and bottom of the stack */ -#ifdef CONFIG_TLS_ALIGNED if (!int_stack) { /* Skip over the TLS data structure at the bottom of the stack */ +#ifdef CONFIG_TLS_ALIGNED DEBUGASSERT((alloc & TLS_STACK_MASK) == 0); +#endif start = alloc + sizeof(struct tls_info_s); } else { start = alloc & ~3; } -#else - UNUSED(int_stack); - start = alloc & ~3; -#endif end = (alloc + size + 3) & ~3; diff --git a/arch/or1k/src/common/up_checkstack.c b/arch/or1k/src/common/up_checkstack.c index e6f4cd9326..aa499a8658 100644 --- a/arch/or1k/src/common/up_checkstack.c +++ b/arch/or1k/src/common/up_checkstack.c @@ -97,22 +97,19 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) /* Get aligned addresses of the top and bottom of the stack */ -#ifdef CONFIG_TLS_ALIGNED if (!int_stack) { /* Skip over the TLS data structure at the bottom of the stack */ +#ifdef CONFIG_TLS_ALIGNED DEBUGASSERT((alloc & TLS_STACK_MASK) == 0); +#endif start = alloc + sizeof(struct tls_info_s); } else { start = alloc & ~3; } -#else - UNUSED(int_stack); - start = alloc & ~3; -#endif end = (alloc + size + 3) & ~3; diff --git a/arch/risc-v/src/common/riscv_checkstack.c b/arch/risc-v/src/common/riscv_checkstack.c index a8f28fa8db..dcc50d580d 100644 --- a/arch/risc-v/src/common/riscv_checkstack.c +++ b/arch/risc-v/src/common/riscv_checkstack.c @@ -91,22 +91,19 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) /* Get aligned addresses of the top and bottom of the stack */ -#ifdef CONFIG_TLS_ALIGNED if (!int_stack) { /* Skip over the TLS data structure at the bottom of the stack */ +#ifdef CONFIG_TLS_ALIGNED DEBUGASSERT((alloc & TLS_STACK_MASK) == 0); +#endif start = alloc + sizeof(struct tls_info_s); } else { start = alloc & ~3; } -#else - UNUSED(int_stack); - start = alloc & ~3; -#endif end = (alloc + size + 3) & ~3; diff --git a/arch/sim/src/sim/up_checkstack.c b/arch/sim/src/sim/up_checkstack.c index 955ea6b863..8d276e9797 100644 --- a/arch/sim/src/sim/up_checkstack.c +++ b/arch/sim/src/sim/up_checkstack.c @@ -89,22 +89,20 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) /* Get aligned addresses of the top and bottom of the stack */ -#ifdef CONFIG_TLS_ALIGNED if (!int_stack) { /* Skip over the TLS data structure at the bottom of the stack */ +#ifdef CONFIG_TLS_ALIGNED DEBUGASSERT((alloc & TLS_STACK_MASK) == 0); +#endif start = alloc + sizeof(struct tls_info_s); } else { start = alloc & ~3; } -#else - UNUSED(int_stack); - start = alloc & ~3; -#endif + end = (alloc + size + 3) & ~3; /* Get the adjusted size based on the top and bottom of the stack */ diff --git a/arch/xtensa/src/common/xtensa_checkstack.c b/arch/xtensa/src/common/xtensa_checkstack.c index cbac16a0d2..8a177cc3a6 100644 --- a/arch/xtensa/src/common/xtensa_checkstack.c +++ b/arch/xtensa/src/common/xtensa_checkstack.c @@ -89,18 +89,14 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) return 0; } - /* Get aligned addresses of the top and bottom of the stack */ + /* Get aligned addresses of the top and bottom of the stack + * Skip over the TLS data structure at the bottom of the stack + */ #ifdef CONFIG_TLS_ALIGNED - - /* Skip over the TLS data structure at the bottom of the stack */ - DEBUGASSERT((alloc & TLS_STACK_MASK) == 0); - start = alloc + sizeof(struct tls_info_s); -#else - start = alloc & ~3; #endif - + start = alloc + sizeof(struct tls_info_s); end = (alloc + size + 3) & ~3; /* Get the adjusted size based on the top and bottom of the stack */