Skip to content

tools/nolibc: add support for stack protector

Thomas Weißschuh linux-kselftest lkml 2 versions – In review

Get series with b4
b4 am [email protected] change-id 20230223-nolibc-stackprotector-d4d5f48ff771

Versions newest first

  1. v2 Latest8 patches 4 repliesIn review
  2. v1 RFC5 patches 8 repliesSuperseded

Changes in v2 from the cover letter

- Code and comments style fixes
- Only use raw syscalls in stackprotector functions
- Remove need for dedicated entrypoint and exec() during tests
- Add more rationale
- Shuffle some code around between commits
- Provide compatibility with the -fno-stack-protector patch
- Remove RFC status
- Link to v1: https://lore.kernel.org/r/[email protected]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8tools/nolibc: add definitions for standard fdstools/include/nolibc/unistd.h+5 -00 replies
2/8tools/nolibc: add helpers for wait() signal exitstools/include/nolibc/types.h+2 -00 replies
3/8tools/nolibc: tests: constify test_namestools/testing/selftests/nolibc/nolibc-test.c+1 -10 replies
4/8tools/nolibc: add support for stack protectortools/include/nolibc/Makefile tools/include/nolibc/nolibc.h tools/include/nolibc/stackprotector.h+56 -20 replies
5/8tools/nolibc: tests: fold in no-stack-protector cflagstools/testing/selftests/nolibc/Makefile+3 -20 replies
6/8tools/nolibc: tests: add test for -fstack-protectortools/testing/selftests/nolibc/Makefile tools/testing/selftests/nolibc/nolibc-test.c+63 -20 replies
7/8tools/nolibc: i386: add stackprotector supporttools/include/nolibc/arch-i386.h tools/testing/selftests/nolibc/Makefile+7 -10 replies
8/8tools/nolibc: x86_64: add stackprotector supporttools/include/nolibc/arch-x86_64.h tools/testing/selftests/nolibc/Makefile+7 -03 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/8] tools/nolibc: add support for stack protector

This is useful when using nolibc for security-critical tools. Using nolibc has the advantage that the code is easily auditable and sandboxable with seccomp as no unexpected syscalls are used. Using compiler-assistent stack protection provides another security mechanism.

For this to work the compiler and libc have to collaborate.

This patch adds the following parts to nolibc that are required by the compiler:

* __stack_chk_guard: random sentinel value
* __stack_chk_fail: handler for detected stack smashes

In addition an initialization function is added that randomizes the sentinel value.

Only support for global guards is implemented.
Register guards are useful in multi-threaded context which nolibc does not provide support for.

---
Changes in v2:
- Code and comments style fixes
- Only use raw syscalls in stackprotector functions
- Remove need for dedicated entrypoint and exec() during tests
- Add more rationale
- Shuffle some code around between commits
- Provide compatibility with the -fno-stack-protector patch
- Remove RFC status
- Link to v1: https://lore.kernel.org/r/[email protected]

This series is based on the current rcu/dev branch of Pauls rcu tree.

---
Thomas Weißschuh (8):
tools/nolibc: add definitions for standard fds tools/nolibc: add helpers for wait() signal exits tools/nolibc: tests: constify test_names tools/nolibc: add support for stack protector tools/nolibc: tests: fold in no-stack-protector cflags tools/nolibc: tests: add test for -fstack-protector tools/nolibc: i386: add stackprotector support tools/nolibc: x86_64: add stackprotector support

 tools/include/nolibc/Makefile                |  4 +-
 tools/include/nolibc/arch-i386.h             |  7 ++-
 tools/include/nolibc/arch-x86_64.h           |  5 +++
 tools/include/nolibc/nolibc.h                |  1 +
 tools/include/nolibc/stackprotector.h        | 53 +++++++++++++++++++++++
 tools/include/nolibc/types.h                 |  2 +
 tools/include/nolibc/unistd.h                |  5 +++
 tools/testing/selftests/nolibc/Makefile      | 11 ++++-
 tools/testing/selftests/nolibc/nolibc-test.c | 64 ++++++++++++++++++++++++++--
 9 files changed, 144 insertions(+), 8 deletions(-)

---
base-commit: a9b8406e51603238941dbc6fa1437f8915254ebb
change-id: 20230223-nolibc-stackprotector-d4d5f48ff771

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>