* [PATCH] selftests/nolibc: make stackprotector probing more robust
@ 2025-06-09 7:39 Thomas Weißschuh
2025-06-09 8:24 ` Willy Tarreau
2025-06-20 7:40 ` Willy Tarreau
0 siblings, 2 replies; 3+ messages in thread
From: Thomas Weißschuh @ 2025-06-09 7:39 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kselftest, linux-kernel, Thomas Weißschuh
nolibc only supports symbol-based stackprotectors, based on the global
variable __stack_chk_guard. Support for this differs between
architectures and toolchains. Some use the symbol mode by default, some
require a flag to enable it and some don't support it at all.
Before the nolibc test Makefile required the availability of
"-mstack-protector-guard=global" to enable stackprotectors.
While this flag makes sure that the correct mode is available it doesn't
work where the correct mode is the only supported one and therefore the
flag is not implemented.
Switch to a more dynamic probing mechanism.
This correctly enables stack protectors for mips, loongarch and m68k.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/testing/selftests/nolibc/Makefile | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index 94176ffe46463548cc9bc787933b6cefa83d6502..853f3a846d4c0fb187922d3063ec3d1a9a30ae46 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -195,7 +195,10 @@ CFLAGS_sparc32 = $(call cc-option,-m32)
ifeq ($(origin XARCH),command line)
CFLAGS_XARCH = $(CFLAGS_$(XARCH))
endif
-CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all))
+_CFLAGS_STACKPROTECTOR = $(call cc-option,-fstack-protector-all) $(call cc-option,-mstack-protector-guard=global)
+CFLAGS_STACKPROTECTOR ?= $(call try-run, \
+ echo 'void foo(void) {}' | $(CC) -x c - -o - -S $(_CFLAGS_STACKPROTECTOR) | grep -q __stack_chk_guard, \
+ $(_CFLAGS_STACKPROTECTOR))
CFLAGS_SANITIZER ?= $(call cc-option,-fsanitize=undefined -fsanitize-trap=all)
CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wextra \
$(call cc-option,-fno-stack-protector) $(call cc-option,-Wmissing-prototypes) \
---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20250530-nolibc-stackprotector-robust-77c9f55a3921
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/nolibc: make stackprotector probing more robust
2025-06-09 7:39 [PATCH] selftests/nolibc: make stackprotector probing more robust Thomas Weißschuh
@ 2025-06-09 8:24 ` Willy Tarreau
2025-06-20 7:40 ` Willy Tarreau
1 sibling, 0 replies; 3+ messages in thread
From: Willy Tarreau @ 2025-06-09 8:24 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: Shuah Khan, linux-kselftest, linux-kernel
Hi Thomas,
On Mon, Jun 09, 2025 at 09:39:16AM +0200, Thomas Weißschuh wrote:
> nolibc only supports symbol-based stackprotectors, based on the global
> variable __stack_chk_guard. Support for this differs between
> architectures and toolchains. Some use the symbol mode by default, some
> require a flag to enable it and some don't support it at all.
>
> Before the nolibc test Makefile required the availability of
> "-mstack-protector-guard=global" to enable stackprotectors.
> While this flag makes sure that the correct mode is available it doesn't
> work where the correct mode is the only supported one and therefore the
> flag is not implemented.
>
> Switch to a more dynamic probing mechanism.
> This correctly enables stack protectors for mips, loongarch and m68k.
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Thanks,
Willy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/nolibc: make stackprotector probing more robust
2025-06-09 7:39 [PATCH] selftests/nolibc: make stackprotector probing more robust Thomas Weißschuh
2025-06-09 8:24 ` Willy Tarreau
@ 2025-06-20 7:40 ` Willy Tarreau
1 sibling, 0 replies; 3+ messages in thread
From: Willy Tarreau @ 2025-06-20 7:40 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: Shuah Khan, linux-kselftest, linux-kernel
On Mon, Jun 09, 2025 at 09:39:16AM +0200, Thomas Weißschuh wrote:
> nolibc only supports symbol-based stackprotectors, based on the global
> variable __stack_chk_guard. Support for this differs between
> architectures and toolchains. Some use the symbol mode by default, some
> require a flag to enable it and some don't support it at all.
>
> Before the nolibc test Makefile required the availability of
> "-mstack-protector-guard=global" to enable stackprotectors.
> While this flag makes sure that the correct mode is available it doesn't
> work where the correct mode is the only supported one and therefore the
> flag is not implemented.
>
> Switch to a more dynamic probing mechanism.
> This correctly enables stack protectors for mips, loongarch and m68k.
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
(...)
Acked-by: Willy Tarreau <w@1wt.eu>
Willy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-20 7:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-09 7:39 [PATCH] selftests/nolibc: make stackprotector probing more robust Thomas Weißschuh
2025-06-09 8:24 ` Willy Tarreau
2025-06-20 7:40 ` Willy Tarreau
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.