Skip to contentSkip to conversation

tools/nolibc: always disable stack protector for tests

PATCH Applied Willy Tarreau 2 participants 7 messages Mar 19, 2023 – Mar 20, 2023

Subsystems (2)
lore
Share & tools
lore

Willy Tarreau

author maintainer
#0 lore raw

cover tools/nolibc: always disable stack protector for tests

Hello Paul,

Thomas noticed that nolibc-test fails to build on compilers that enable stack protectors by default. Passing -fno-stack-protector when supported addresses the problem.

I verified that all supported archs continue to work after his patch is applied, and that it applies without conflict (and works) both on top of your latest dev tree and on top of Linus' master branch. Thus I think it can make sense to queue it with your next series of fixes and have it for 6.3 given that it addresses build issues for some developers.

Thanks!
Willy
---
Thomas Weißschuh (1):
tools/nolibc: always disable stack protector for tests

 tools/testing/selftests/nolibc/Makefile | 3 +++
 1 file changed, 3 insertions(+)
Signature · 1 line
2.17.5
author maintainer
#1 lore raw

PATCH 1/1 tools/nolibc: always disable stack protector for tests

From: Thomas Weißschuh <[email protected]>

Stack protectors need support from libc.
This support is not provided by nolibc which leads to compiler errors when stack protectors are enabled by default in a compiler:

CC nolibc-test
/usr/bin/ld: /tmp/ccqbHEPk.o: in function `stat':
nolibc-test.c:(.text+0x1d1): undefined reference to `__stack_chk_fail'
/usr/bin/ld: /tmp/ccqbHEPk.o: in function `poll.constprop.0':
nolibc-test.c:(.text+0x37b): undefined reference to `__stack_chk_fail'
/usr/bin/ld: /tmp/ccqbHEPk.o: in function `vfprintf.constprop.0':
nolibc-test.c:(.text+0x712): undefined reference to `__stack_chk_fail'
/usr/bin/ld: /tmp/ccqbHEPk.o: in function `pad_spc.constprop.0':
nolibc-test.c:(.text+0x80d): undefined reference to `__stack_chk_fail'
/usr/bin/ld: /tmp/ccqbHEPk.o: in function `printf':
nolibc-test.c:(.text+0x8c4): undefined reference to `__stack_chk_fail'
/usr/bin/ld: /tmp/ccqbHEPk.o:nolibc-test.c:(.text+0x12d4): more undefined references to `__stack_chk_fail' follow
collect2: error: ld returned 1 exit status

---
 tools/testing/selftests/nolibc/Makefile | 3 +++
 1 file changed, 3 insertions(+)
tools/testing/selftests/nolibc/Makefile +3 -0
index 8fe61d3e3cce..874d141da8c4 100644
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for nolibc tests
 include ../../../scripts/Makefile.include
+# We need this for the "cc-option" macro.
+include ../../../build/Build.include
 
 # we're in ".../tools/testing/selftests/nolibc"
 ifeq ($(srctree),)
@@ -72,6 +74,7 @@ endif
 
 CFLAGS_s390 = -m64
 CFLAGS  ?= -Os -fno-ident -fno-asynchronous-unwind-tables $(CFLAGS_$(ARCH))
+CFLAGS  += $(call cc-option,-fno-stack-protector)
 LDFLAGS := -s
 
 help:
Signature · 1 line
2.17.5
#2 lore raw
In reply to Willy Tarreau
Quoted 11 lines · Willy Tarreau

Hello Paul,

Thomas noticed that nolibc-test fails to build on compilers that enable stack protectors by default. Passing -fno-stack-protector when supported addresses the problem.

I verified that all supported archs continue to work after his patch is applied, and that it applies without conflict (and works) both on top of your latest dev tree and on top of Linus' master branch. Thus I think it can make sense to queue it with your next series of fixes and have it for 6.3 given that it addresses build issues for some developers.

Queued and pushed, thank you both!

Just to make sure I understand, you would like me to add this to the serieses from Vincent, yourself, and Feiyang that are set up to go into the next merge window, correct?

If you instead would like me to push it to Linus directly into the v6.3 release as a regression fix late this coming week, please let me know.

Thanx, Paul

Quoted 12 lines

Thanks!
Willy
---
Thomas Weißschuh (1):
tools/nolibc: always disable stack protector for tests

 tools/testing/selftests/nolibc/Makefile | 3 +++
 1 file changed, 3 insertions(+)
Signature · 1 line
2.17.5
author maintainer
#3 lore raw

Hi Paul,

Quoted 1 line · Paul E. McKenney

Queued and pushed, thank you both!

Thank you!

Quoted 6 lines

Just to make sure I understand, you would like me to add this to the serieses from Vincent, yourself, and Feiyang that are set up to go into the next merge window, correct?

If you instead would like me to push it to Linus directly into the v6.3 release as a regression fix late this coming week, please let me know.

It would indeed be preferable for 6.3 as it fixes issues, but it's not critical at all, just an annoyance for some developers. So if you have a series of fixes pending to be sent soon, it would be nice to add it there.

Thanks!
Willy

#4 lore raw
Quoted 11 lines · Willy Tarreau

Hi Paul,

Quoted 1 line · Paul E. McKenney

Queued and pushed, thank you both!

Thank you!

Quoted 4 lines

Just to make sure I understand, you would like me to add this to the serieses from Vincent, yourself, and Feiyang that are set up to go into the next merge window, correct?

Quoted 6 lines
Quoted 2 lines

If you instead would like me to push it to Linus directly into the v6.3 release as a regression fix late this coming week, please let me know.

It would indeed be preferable for 6.3 as it fixes issues, but it's not critical at all, just an annoyance for some developers. So if you have a series of fixes pending to be sent soon, it would be nice to add it there.

Very well, here is what I currently have for nolibc, from newest to oldest:

7712ec32cbda selftests/nolibc: Adjust indentation for Makefile
96218cfc79eb selftests/nolibc: Add support for LoongArch
cab6bbd00f2a tools/nolibc: Add support for LoongArch
496921e4724c tools/nolibc: Add statx() and make stat() rely on statx() if necessary 97a15c47b98c tools/nolibc: Include linux/fcntl.h and remove duplicate code de06f2fe1aac tools/nolibc: check for S_I* macros before defining them 7fb54b517d44 selftests/nolibc: skip the chroot_root and link_dir tests when not privileged 296659c6e551 tools/nolibc: add getuid() and geteuid()
bd9a87d64994 tools/nolibc: add tests for the integer limits in stdint.h 2d1813a7ef67 tools/nolibc: enlarge column width of tests
5dbcbb2da574 tools/nolibc: add integer types and integer limit macros 111bb94f67eb tools/nolibc: add stdint.h
2dbf8575b2da tools/nolibc: Add gitignore to avoid git complaints about sysroot

I will take the new commit, rebase it to precede the first of the above, so that the stack will look like this:

7712ec32cbda selftests/nolibc: Adjust indentation for Makefile
96218cfc79eb selftests/nolibc: Add support for LoongArch
cab6bbd00f2a tools/nolibc: Add support for LoongArch
496921e4724c tools/nolibc: Add statx() and make stat() rely on statx() if necessary 97a15c47b98c tools/nolibc: Include linux/fcntl.h and remove duplicate code de06f2fe1aac tools/nolibc: check for S_I* macros before defining them 7fb54b517d44 selftests/nolibc: skip the chroot_root and link_dir tests when not privileged 296659c6e551 tools/nolibc: add getuid() and geteuid()
bd9a87d64994 tools/nolibc: add tests for the integer limits in stdint.h 2d1813a7ef67 tools/nolibc: enlarge column width of tests
5dbcbb2da574 tools/nolibc: add integer types and integer limit macros 111bb94f67eb tools/nolibc: add stdint.h
2dbf8575b2da tools/nolibc: Add gitignore to avoid git complaints about sysroot ???????????? tools/nolibc: always disable stack protector for tests

Then if tests, -next, and kernel test robot are kind, I will send a pull request to Linus for the "always disable stack protector for tests" commit. The rest I send for the upcoming merge window.

Please let me know if I am missing something.

Thanx, Paul

author maintainer
#5 lore raw
Quoted 54 lines · Paul E. McKenney
Quoted 11 lines · Willy Tarreau

Hi Paul,

Quoted 1 line · Paul E. McKenney

Queued and pushed, thank you both!

Thank you!

Quoted 4 lines

Just to make sure I understand, you would like me to add this to the serieses from Vincent, yourself, and Feiyang that are set up to go into the next merge window, correct?

Quoted 6 lines
Quoted 2 lines

If you instead would like me to push it to Linus directly into the v6.3 release as a regression fix late this coming week, please let me know.

It would indeed be preferable for 6.3 as it fixes issues, but it's not critical at all, just an annoyance for some developers. So if you have a series of fixes pending to be sent soon, it would be nice to add it there.

Very well, here is what I currently have for nolibc, from newest to oldest:

7712ec32cbda selftests/nolibc: Adjust indentation for Makefile
96218cfc79eb selftests/nolibc: Add support for LoongArch
cab6bbd00f2a tools/nolibc: Add support for LoongArch
496921e4724c tools/nolibc: Add statx() and make stat() rely on statx() if necessary 97a15c47b98c tools/nolibc: Include linux/fcntl.h and remove duplicate code de06f2fe1aac tools/nolibc: check for S_I* macros before defining them 7fb54b517d44 selftests/nolibc: skip the chroot_root and link_dir tests when not privileged 296659c6e551 tools/nolibc: add getuid() and geteuid()
bd9a87d64994 tools/nolibc: add tests for the integer limits in stdint.h 2d1813a7ef67 tools/nolibc: enlarge column width of tests
5dbcbb2da574 tools/nolibc: add integer types and integer limit macros 111bb94f67eb tools/nolibc: add stdint.h
2dbf8575b2da tools/nolibc: Add gitignore to avoid git complaints about sysroot

I will take the new commit, rebase it to precede the first of the above, so that the stack will look like this:

7712ec32cbda selftests/nolibc: Adjust indentation for Makefile
96218cfc79eb selftests/nolibc: Add support for LoongArch
cab6bbd00f2a tools/nolibc: Add support for LoongArch
496921e4724c tools/nolibc: Add statx() and make stat() rely on statx() if necessary 97a15c47b98c tools/nolibc: Include linux/fcntl.h and remove duplicate code de06f2fe1aac tools/nolibc: check for S_I* macros before defining them 7fb54b517d44 selftests/nolibc: skip the chroot_root and link_dir tests when not privileged 296659c6e551 tools/nolibc: add getuid() and geteuid()
bd9a87d64994 tools/nolibc: add tests for the integer limits in stdint.h 2d1813a7ef67 tools/nolibc: enlarge column width of tests
5dbcbb2da574 tools/nolibc: add integer types and integer limit macros 111bb94f67eb tools/nolibc: add stdint.h
2dbf8575b2da tools/nolibc: Add gitignore to avoid git complaints about sysroot ???????????? tools/nolibc: always disable stack protector for tests

Quoted 5 lines

Then if tests, -next, and kernel test robot are kind, I will send a pull request to Linus for the "always disable stack protector for tests" commit. The rest I send for the upcoming merge window.

Please let me know if I am missing something.

This is perfect, thank you very much, Paul!

Willy

#6 lore raw
Quoted 55 lines · Willy Tarreau
Quoted 54 lines · Paul E. McKenney
Quoted 11 lines · Willy Tarreau

Hi Paul,

Quoted 1 line · Paul E. McKenney

Queued and pushed, thank you both!

Thank you!

Quoted 4 lines

Just to make sure I understand, you would like me to add this to the serieses from Vincent, yourself, and Feiyang that are set up to go into the next merge window, correct?

Quoted 6 lines
Quoted 2 lines

If you instead would like me to push it to Linus directly into the v6.3 release as a regression fix late this coming week, please let me know.

It would indeed be preferable for 6.3 as it fixes issues, but it's not critical at all, just an annoyance for some developers. So if you have a series of fixes pending to be sent soon, it would be nice to add it there.

Very well, here is what I currently have for nolibc, from newest to oldest:

7712ec32cbda selftests/nolibc: Adjust indentation for Makefile
96218cfc79eb selftests/nolibc: Add support for LoongArch
cab6bbd00f2a tools/nolibc: Add support for LoongArch
496921e4724c tools/nolibc: Add statx() and make stat() rely on statx() if necessary 97a15c47b98c tools/nolibc: Include linux/fcntl.h and remove duplicate code de06f2fe1aac tools/nolibc: check for S_I* macros before defining them 7fb54b517d44 selftests/nolibc: skip the chroot_root and link_dir tests when not privileged 296659c6e551 tools/nolibc: add getuid() and geteuid()
bd9a87d64994 tools/nolibc: add tests for the integer limits in stdint.h 2d1813a7ef67 tools/nolibc: enlarge column width of tests
5dbcbb2da574 tools/nolibc: add integer types and integer limit macros 111bb94f67eb tools/nolibc: add stdint.h
2dbf8575b2da tools/nolibc: Add gitignore to avoid git complaints about sysroot

I will take the new commit, rebase it to precede the first of the above, so that the stack will look like this:

7712ec32cbda selftests/nolibc: Adjust indentation for Makefile
96218cfc79eb selftests/nolibc: Add support for LoongArch
cab6bbd00f2a tools/nolibc: Add support for LoongArch
496921e4724c tools/nolibc: Add statx() and make stat() rely on statx() if necessary 97a15c47b98c tools/nolibc: Include linux/fcntl.h and remove duplicate code de06f2fe1aac tools/nolibc: check for S_I* macros before defining them 7fb54b517d44 selftests/nolibc: skip the chroot_root and link_dir tests when not privileged 296659c6e551 tools/nolibc: add getuid() and geteuid()
bd9a87d64994 tools/nolibc: add tests for the integer limits in stdint.h 2d1813a7ef67 tools/nolibc: enlarge column width of tests
5dbcbb2da574 tools/nolibc: add integer types and integer limit macros 111bb94f67eb tools/nolibc: add stdint.h
2dbf8575b2da tools/nolibc: Add gitignore to avoid git complaints about sysroot ???????????? tools/nolibc: always disable stack protector for tests

Quoted 7 lines
Quoted 5 lines

Then if tests, -next, and kernel test robot are kind, I will send a pull request to Linus for the "always disable stack protector for tests" commit. The rest I send for the upcoming merge window.

Please let me know if I am missing something.

This is perfect, thank you very much, Paul!

Done!

Thanx, Paul