Skip to content

Commit b083cc8

Browse files
l0kodkees
authored andcommitted
selftests/exec: Add 32 tests for AT_EXECVE_CHECK and exec securebits
Test that checks performed by execveat(..., AT_EXECVE_CHECK) are consistent with noexec mount points and file execute permissions. Test that SECBIT_EXEC_RESTRICT_FILE and SECBIT_EXEC_DENY_INTERACTIVE are inherited by child processes and that they can be pinned with the appropriate SECBIT_EXEC_RESTRICT_FILE_LOCKED and SECBIT_EXEC_DENY_INTERACTIVE_LOCKED bits. Cc: Al Viro <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Kees Cook <[email protected]> Cc: Paul Moore <[email protected]> Cc: Serge Hallyn <[email protected]> Signed-off-by: Mickaël Salaün <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent a0623b2 commit b083cc8

File tree

5 files changed

+472
-0
lines changed

5 files changed

+472
-0
lines changed

tools/testing/selftests/exec/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ execveat.ephemeral
99
execveat.denatured
1010
non-regular
1111
null-argv
12+
/check-exec
13+
/false
1214
/load_address.*
1315
!load_address.c
1416
/recursion-depth

tools/testing/selftests/exec/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# SPDX-License-Identifier: GPL-2.0
22
CFLAGS = -Wall
33
CFLAGS += -Wno-nonnull
4+
CFLAGS += $(KHDR_INCLUDES)
5+
6+
LDLIBS += -lcap
47

58
ALIGNS := 0x1000 0x200000 0x1000000
69
ALIGN_PIES := $(patsubst %,load_address.%,$(ALIGNS))
@@ -9,12 +12,14 @@ ALIGNMENT_TESTS := $(ALIGN_PIES) $(ALIGN_STATIC_PIES)
912

1013
TEST_PROGS := binfmt_script.py
1114
TEST_GEN_PROGS := execveat non-regular $(ALIGNMENT_TESTS)
15+
TEST_GEN_PROGS_EXTENDED := false
1216
TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
1317
# Makefile is a run-time dependency, since it's accessed by the execveat test
1418
TEST_FILES := Makefile
1519

1620
TEST_GEN_PROGS += recursion-depth
1721
TEST_GEN_PROGS += null-argv
22+
TEST_GEN_PROGS += check-exec
1823

1924
EXTRA_CLEAN := $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPUT)/xxxxx* \
2025
$(OUTPUT)/S_I*.test
@@ -38,3 +43,5 @@ $(OUTPUT)/load_address.0x%: load_address.c
3843
$(OUTPUT)/load_address.static.0x%: load_address.c
3944
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=$(lastword $(subst ., ,$@)) \
4045
-fPIE -static-pie $< -o $@
46+
$(OUTPUT)/false: false.c
47+
$(CC) $(CFLAGS) $(LDFLAGS) -static $< -o $@

0 commit comments

Comments
 (0)