mailing list of musl libc
 help / color / mirror / code / Atom feed
* [RFC PATCH v2 1/4] disable check for buggy brk implementations when SafeStack is enabled
@ 2016-10-28 19:56 LeMay, Michael
  2016-11-01 22:30 ` Szabolcs Nagy
  0 siblings, 1 reply; 2+ messages in thread
From: LeMay, Michael @ 2016-10-28 19:56 UTC (permalink / raw)
  To: musl

The check relies on comparing the addresses of stack-allocated objects
to addresses returned by the brk syscall.  SafeStack moves the
allocations to the unsafe stack, breaking the check.  This patch
disables the check when SafeStack is enabled.

Signed-off-by: Michael LeMay <michael.lemay@...el.com>
---
 src/malloc/expand_heap.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/malloc/expand_heap.c b/src/malloc/expand_heap.c
index d8c0be7..af51451 100644
--- a/src/malloc/expand_heap.c
+++ b/src/malloc/expand_heap.c
@@ -13,6 +13,7 @@
 
 static int traverses_stack_p(uintptr_t old, uintptr_t new)
 {
+#if !defined(__has_feature) || !__has_feature(safe_stack)
 	const uintptr_t len = 8<<20;
 	uintptr_t a, b;
 
@@ -23,6 +24,7 @@ static int traverses_stack_p(uintptr_t old, uintptr_t new)
 	b = (uintptr_t)&b;
 	a = b > len ? b-len : 0;
 	if (new>a && old<b) return 1;
+#endif
 
 	return 0;
 }
-- 
2.7.4



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [RFC PATCH v2 1/4] disable check for buggy brk implementations when SafeStack is enabled
  2016-10-28 19:56 [RFC PATCH v2 1/4] disable check for buggy brk implementations when SafeStack is enabled LeMay, Michael
@ 2016-11-01 22:30 ` Szabolcs Nagy
  0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2016-11-01 22:30 UTC (permalink / raw)
  To: LeMay, Michael; +Cc: musl

* LeMay, Michael <michael.lemay@intel.com> [2016-10-28 19:56:18 +0000]:
> The check relies on comparing the addresses of stack-allocated objects
> to addresses returned by the brk syscall.  SafeStack moves the
> allocations to the unsafe stack, breaking the check.  This patch
> disables the check when SafeStack is enabled.
> 
> Signed-off-by: Michael LeMay <michael.lemay@...el.com>
> ---
>  src/malloc/expand_heap.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/malloc/expand_heap.c b/src/malloc/expand_heap.c
> index d8c0be7..af51451 100644
> --- a/src/malloc/expand_heap.c
> +++ b/src/malloc/expand_heap.c
> @@ -13,6 +13,7 @@
>  
>  static int traverses_stack_p(uintptr_t old, uintptr_t new)
>  {
> +#if !defined(__has_feature) || !__has_feature(safe_stack)

preprocessing this fails on any released version of gcc
https://godbolt.org/g/hHWEzI

if __has_feature is not defined it expands to 0 and 0(safe_stack)
is invalid syntax.

e.g. this works:

#ifdef __has_feature
#if __has_feature(safe_stack)
#define HAS_SAFE_STACK 1
#endif
#endif

>  	const uintptr_t len = 8<<20;
>  	uintptr_t a, b;
>  
> @@ -23,6 +24,7 @@ static int traverses_stack_p(uintptr_t old, uintptr_t new)
>  	b = (uintptr_t)&b;
>  	a = b > len ? b-len : 0;
>  	if (new>a && old<b) return 1;
> +#endif
>  
>  	return 0;
>  }
> -- 
> 2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-01 22:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-28 19:56 [RFC PATCH v2 1/4] disable check for buggy brk implementations when SafeStack is enabled LeMay, Michael
2016-11-01 22:30 ` Szabolcs Nagy

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).