aboutsummaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)AuthorFilesLines
2019-05-14selftests: drivers: Create .gitignore to include /dma-buf/udmabufKelsey Skunberg1-0/+1
Create ../selftests/drivers/.gitignore which holds the following file name created after compiling: - /dma-buf/udmabuf Signed-off-by: Kelsey Skunberg <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-05-14selftests: pidfd: Create .gitignore to include pidfd_testKelsey Skunberg1-0/+1
Create ../selftests/pidfd/.gitignore which holds the following file name created after compiling: - pidfd_test Signed-off-by: Kelsey Skunberg <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-05-13selftests: fix bpf build/test workflow regression when KBUILD_OUTPUT is setShuah Khan1-9/+3
commit 8ce72dc32578 ("selftests: fix headers_install circular dependency") broke bpf build/test workflow. When KBUILD_OUTPUT is set, bpf objects end up in KBUILD_OUTPUT build directory instead of in ../selftests/bpf. The following bpf workflow breaks when it can't find the test_verifier: cd tools/testing/selftests/bpf; make; ./test_verifier; Fix it to set OUTPUT only when it is undefined in lib.mk. It didn't need to be set in the first place. Fixes: 8ce72dc32578 ("selftests: fix headers_install circular dependency") Reported-by: Alexei Starovoitov <[email protected]> Signed-off-by: Shuah Khan <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-05-09selftests: fix install target to use default install pathShuah Khan1-2/+8
Install target fails when INSTALL_PATH is undefined. Fix install target to use "output_dir/install as the default install location. "output_dir" is either the root of selftests directory under kernel source tree or output directory specified by O= or KBUILD_OUTPUT. e.g: make -C tools/testing/selftests install <installs under tools/testing/selftests/install> make O=/tmp/kselftest -C tools/testing/selftests install <installs under /tmp/kselftest/install> export KBUILD_OUTPUT=/tmp/kselftest make -C tools/testing/selftests install <installs under /tmp/kselftest/install> In addition, add "all" target as dependency to "install" to build and install using a single command. Signed-off-by: Shuah Khan <[email protected]>
2019-05-07rseq/selftests: add -no-integrated-as for clangMathieu Desnoyers1-1/+7
Ongoing work for asm goto support from clang requires the -no-integrated-as compiler flag. This compiler flag is present in the toplevel kernel Makefile, but is not replicated for selftests. Add it specifically for the rseq selftest which requires asm goto. Link: https://reviews.llvm.org/D56571 Signed-off-by: Mathieu Desnoyers <[email protected]> CC: Nick Desaulniers <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Joel Fernandes <[email protected]> CC: Peter Zijlstra <[email protected]> CC: Catalin Marinas <[email protected]> CC: Dave Watson <[email protected]> CC: Will Deacon <[email protected]> CC: Shuah Khan <[email protected]> CC: Andi Kleen <[email protected]> CC: [email protected] CC: "H . Peter Anvin" <[email protected]> CC: Chris Lameter <[email protected]> CC: Russell King <[email protected]> CC: Michael Kerrisk <[email protected]> CC: "Paul E . McKenney" <[email protected]> CC: Paul Turner <[email protected]> CC: Boqun Feng <[email protected]> CC: Josh Triplett <[email protected]> CC: Steven Rostedt <[email protected]> CC: Ben Maurer <[email protected]> CC: [email protected] CC: Andy Lutomirski <[email protected]> CC: Andrew Morton <[email protected]> CC: Linus Torvalds <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-05-07rseq/selftests: mips: use break instruction for RSEQ_SIGMathieu Desnoyers1-1/+33
Use break as guard instruction for the restartable sequence abort handler. Previously, the chosen signature was simply data, based on the assumption that it could always sit in a literal pool. However, some compilation environments favor disabling literal pool. Therefore, ensure the signature is a valid uncommon trap instruction. Suggested-by: Paul Burton <[email protected]> Signed-off-by: Mathieu Desnoyers <[email protected]> CC: Paul Burton <[email protected]> CC: James Hogan <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Boqun Feng <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Shuah Khan <[email protected]>
2019-05-07rseq/selftests: powerpc code signature: generate valid instructionsMathieu Desnoyers1-1/+9
Use "twui" as the guard instruction for the restartable sequence abort handler. Signed-off-by: Mathieu Desnoyers <[email protected]> CC: Benjamin Herrenschmidt <[email protected]> CC: Paul Mackerras <[email protected]> CC: Michael Ellerman <[email protected]> CC: Boqun Feng <[email protected]> CC: Peter Zijlstra <[email protected]> CC: "Paul E. McKenney" <[email protected]> CC: Alan Modra <[email protected]> CC: [email protected] Signed-off-by: Shuah Khan <[email protected]>
2019-05-07rseq/selftests: aarch64 code signature: handle big-endian environmentMathieu Desnoyers1-2/+15
Handle compiling with -mbig-endian on aarch64, which generates binaries with mixed code vs data endianness (little endian code, big endian data). Else mismatch between code endianness for the generated signatures and data endianness for the RSEQ_SIG parameter passed to the rseq registration will trigger application segmentation faults when the kernel try to abort rseq critical sections. Signed-off-by: Mathieu Desnoyers <[email protected]> Acked-by: Will Deacon <[email protected]> CC: Peter Zijlstra <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Joel Fernandes <[email protected]> CC: Catalin Marinas <[email protected]> CC: Dave Watson <[email protected]> CC: Will Deacon <[email protected]> CC: Shuah Khan <[email protected]> CC: Andi Kleen <[email protected]> CC: [email protected] CC: "H . Peter Anvin" <[email protected]> CC: Chris Lameter <[email protected]> CC: Russell King <[email protected]> CC: Michael Kerrisk <[email protected]> CC: "Paul E . McKenney" <[email protected]> CC: Paul Turner <[email protected]> CC: Boqun Feng <[email protected]> CC: Josh Triplett <[email protected]> CC: Steven Rostedt <[email protected]> CC: Ben Maurer <[email protected]> CC: [email protected] CC: Andy Lutomirski <[email protected]> CC: Andrew Morton <[email protected]> CC: Linus Torvalds <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-05-07rseq/selftests: arm: use udf instruction for RSEQ_SIGMathieu Desnoyers1-2/+50
Use udf as the guard instruction for the restartable sequence abort handler. Previously, the chosen signature was not a valid instruction, based on the assumption that it could always sit in a literal pool. However, there are compilation environments in which literal pools are not available, for instance execute-only code. Therefore, we need to choose a signature value that is also a valid instruction. Handle compiling with -mbig-endian on ARMv6+, which generates binaries with mixed code vs data endianness (little endian code, big endian data). Else mismatch between code endianness for the generated signatures and data endianness for the RSEQ_SIG parameter passed to the rseq registration will trigger application segmentation faults when the kernel try to abort rseq critical sections. Prior to ARMv6, -mbig-endian generates big-endian code and data, so endianness should not be reversed in that case. Signed-off-by: Mathieu Desnoyers <[email protected]> CC: Peter Zijlstra <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Joel Fernandes <[email protected]> CC: Catalin Marinas <[email protected]> CC: Dave Watson <[email protected]> CC: Will Deacon <[email protected]> CC: Shuah Khan <[email protected]> CC: Andi Kleen <[email protected]> CC: [email protected] CC: "H . Peter Anvin" <[email protected]> CC: Chris Lameter <[email protected]> CC: Russell King <[email protected]> CC: Michael Kerrisk <[email protected]> CC: "Paul E . McKenney" <[email protected]> CC: Paul Turner <[email protected]> CC: Boqun Feng <[email protected]> CC: Josh Triplett <[email protected]> CC: Steven Rostedt <[email protected]> CC: Ben Maurer <[email protected]> CC: [email protected] CC: Andy Lutomirski <[email protected]> CC: Andrew Morton <[email protected]> CC: Linus Torvalds <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-05-07rseq/selftests: s390: use trap4 for RSEQ_SIGMartin Schwidefsky1-1/+8
Use trap4 as the guard instruction for the restartable sequence abort handler. Signed-off-by: Martin Schwidefsky <[email protected]> Signed-off-by: Mathieu Desnoyers <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-05-07rseq/selftests: x86: use ud1 instruction as RSEQ_SIG opcodeMathieu Desnoyers1-4/+11
Use ud1 as the guard instruction for the restartable sequence abort handler. Its benefit compared to nopl is to trap execution if the program ends up trying to execute it by mistake, which makes debugging easier. The 4-byte signature per se is unchanged (it is the instruction operand). Only the opcode is changed from nopl to ud1. Signed-off-by: Mathieu Desnoyers <[email protected]> Suggested-by: Peter Zijlstra <[email protected]> CC: Peter Zijlstra <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Joel Fernandes <[email protected]> CC: Catalin Marinas <[email protected]> CC: Dave Watson <[email protected]> CC: Will Deacon <[email protected]> CC: Shuah Khan <[email protected]> CC: Andi Kleen <[email protected]> CC: [email protected] CC: "H . Peter Anvin" <[email protected]> CC: Chris Lameter <[email protected]> CC: Russell King <[email protected]> CC: Michael Kerrisk <[email protected]> CC: "Paul E . McKenney" <[email protected]> CC: Paul Turner <[email protected]> CC: Boqun Feng <[email protected]> CC: Josh Triplett <[email protected]> CC: Steven Rostedt <[email protected]> CC: Ben Maurer <[email protected]> CC: [email protected] CC: Andy Lutomirski <[email protected]> CC: Andrew Morton <[email protected]> CC: Linus Torvalds <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-05-07rseq/selftests: s390: use jg instruction for jumps outside of the asmMathieu Desnoyers1-2/+2
The branch target range of the "j" instruction is 64K, which is not enough for the general case. Suggested-by: Martin Schwidefsky <[email protected]> Signed-off-by: Mathieu Desnoyers <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Joel Fernandes <[email protected]> CC: Peter Zijlstra <[email protected]> CC: Catalin Marinas <[email protected]> CC: Dave Watson <[email protected]> CC: Will Deacon <[email protected]> CC: Shuah Khan <[email protected]> CC: Andi Kleen <[email protected]> CC: [email protected] CC: "H . Peter Anvin" <[email protected]> CC: Chris Lameter <[email protected]> CC: Russell King <[email protected]> CC: Michael Kerrisk <[email protected]> CC: "Paul E . McKenney" <[email protected]> CC: Paul Turner <[email protected]> CC: Boqun Feng <[email protected]> CC: Josh Triplett <[email protected]> CC: Steven Rostedt <[email protected]> CC: Ben Maurer <[email protected]> CC: [email protected] CC: Andy Lutomirski <[email protected]> CC: Andrew Morton <[email protected]> CC: Linus Torvalds <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-05-07rseq/selftests: Use __rseq_handled symbol to coexist with glibcMathieu Desnoyers2-8/+48
In order to integrate rseq into user-space applications, expose a __rseq_handled symbol so many rseq users can be linked into the same application (e.g. librseq and glibc). The __rseq_refcount TLS variable is static to the librseq library. It ensures that rseq syscall registration/unregistration happens only for the most early/late caller to rseq_{,un}register_current_thread for each thread, thus ensuring that rseq is registered across the lifetime of all rseq users for a given thread. Signed-off-by: Mathieu Desnoyers <[email protected]> CC: Shuah Khan <[email protected]> CC: Carlos O'Donell <[email protected]> CC: Florian Weimer <[email protected]> CC: Joseph Myers <[email protected]> CC: Szabolcs Nagy <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Ben Maurer <[email protected]> CC: Peter Zijlstra <[email protected]> CC: "Paul E. McKenney" <[email protected]> CC: Boqun Feng <[email protected]> CC: Will Deacon <[email protected]> CC: Dave Watson <[email protected]> CC: Paul Turner <[email protected]> CC: [email protected] Signed-off-by: Shuah Khan <[email protected]>
2019-05-07rseq/selftests: Introduce __rseq_cs_ptr_array, rename __rseq_table to __rseq_csMathieu Desnoyers6-51/+81
The entries within __rseq_table are aligned on 32 bytes due to linux/rseq.h struct rseq_cs uapi requirements, but the start of the __rseq_table section is not guaranteed to be 32-byte aligned. It can cause padding to be added at the start of the section, which makes it hard to use as an array of items by debuggers. Considering that __rseq_table does not really consist of a table due to the presence of padding, rename this section to __rseq_cs. Create a new __rseq_cs_ptr_array section which contains 64-bit packed pointers to entries within the __rseq_cs section. Signed-off-by: Mathieu Desnoyers <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Joel Fernandes <[email protected]> CC: Peter Zijlstra <[email protected]> CC: Catalin Marinas <[email protected]> CC: Dave Watson <[email protected]> CC: Will Deacon <[email protected]> CC: Shuah Khan <[email protected]> CC: Andi Kleen <[email protected]> CC: [email protected] CC: "H . Peter Anvin" <[email protected]> CC: Chris Lameter <[email protected]> CC: Russell King <[email protected]> CC: Michael Kerrisk <[email protected]> CC: "Paul E . McKenney" <[email protected]> CC: Paul Turner <[email protected]> CC: Boqun Feng <[email protected]> CC: Josh Triplett <[email protected]> CC: Steven Rostedt <[email protected]> CC: Ben Maurer <[email protected]> CC: [email protected] CC: Andy Lutomirski <[email protected]> CC: Andrew Morton <[email protected]> CC: Linus Torvalds <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-05-07rseq/selftests: Add __rseq_exit_point_array section for debuggersMathieu Desnoyers6-0/+372
Knowing all exit points is useful to assist debuggers stepping over the rseq critical sections without requiring them to disassemble the content of the critical section to figure out the exit points. Signed-off-by: Mathieu Desnoyers <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Joel Fernandes <[email protected]> CC: Peter Zijlstra <[email protected]> CC: Catalin Marinas <[email protected]> CC: Dave Watson <[email protected]> CC: Will Deacon <[email protected]> CC: Shuah Khan <[email protected]> CC: Andi Kleen <[email protected]> CC: [email protected] CC: "H . Peter Anvin" <[email protected]> CC: Chris Lameter <[email protected]> CC: Russell King <[email protected]> CC: Michael Kerrisk <[email protected]> CC: "Paul E . McKenney" <[email protected]> CC: Paul Turner <[email protected]> CC: Boqun Feng <[email protected]> CC: Josh Triplett <[email protected]> CC: Steven Rostedt <[email protected]> CC: Ben Maurer <[email protected]> CC: [email protected] CC: Andy Lutomirski <[email protected]> CC: Andrew Morton <[email protected]> CC: Linus Torvalds <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-05-07rseq/selftests: x86: Work-around bogus gcc-8 optimisationMathieu Desnoyers1-74/+70
gcc-8 version 8.1.0, 8.2.0, and 8.3.0 generate broken assembler with asm goto that have a thread-local storage "m" input operand on both x86-32 and x86-64. For instance: __thread int var; static int fct(void) { asm goto ( "jmp %l[testlabel]\n\t" : : [var] "m" (var) : : testlabel); return 0; testlabel: return 1; } int main() { return fct(); } % gcc-8 -O2 -o test-asm-goto test-asm-goto.c /tmp/ccAdHJbe.o: In function `main': test-asm-goto.c:(.text.startup+0x1): undefined reference to `.L2' collect2: error: ld returned 1 exit status % gcc-8 -m32 -O2 -o test-asm-goto test-asm-goto.c /tmp/ccREsVXA.o: In function `main': test-asm-goto.c:(.text.startup+0x1): undefined reference to `.L2' collect2: error: ld returned 1 exit status Work-around this compiler bug in the rseq-x86.h header by passing the address of the __rseq_abi TLS as a register operand rather than using the "m" input operand. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90193 Signed-off-by: Mathieu Desnoyers <[email protected]> CC: Ingo Molnar <[email protected]> CC: Peter Zijlstra <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Joel Fernandes <[email protected]> CC: Catalin Marinas <[email protected]> CC: Dave Watson <[email protected]> CC: Will Deacon <[email protected]> CC: Shuah Khan <[email protected]> CC: Andi Kleen <[email protected]> CC: [email protected] CC: "H . Peter Anvin" <[email protected]> CC: Chris Lameter <[email protected]> CC: Russell King <[email protected]> CC: Michael Kerrisk <[email protected]> CC: "Paul E . McKenney" <[email protected]> CC: Paul Turner <[email protected]> CC: Boqun Feng <[email protected]> CC: Josh Triplett <[email protected]> CC: Steven Rostedt <[email protected]> CC: Ben Maurer <[email protected]> CC: [email protected] CC: Andy Lutomirski <[email protected]> CC: Andrew Morton <[email protected]> CC: Linus Torvalds <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-25selftests: Add test plan API to kselftest.h and adjust callersKees Cook16-8/+48
The test plan for TAP needs to be declared immediately after the header. This adds the test plan API to kselftest.h and updates all callers to declare their expected test counts. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-25selftests: Remove KSFT_TAP_LEVELKees Cook2-7/+0
Since sub-testing can now be detected by indentation level, this removes KSFT_TAP_LEVEL so that subtests report their TAP header for later parsing. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-25selftests: Move test output to diagnostic linesKees Cook5-6/+60
This changes the selftest output so that each test's output is prefixed with "# " as a TAP "diagnostic line". This creates a bit of a kernel-specific TAP dialect where the diagnostics precede the results. The TAP spec isn't entirely clear about this, though, so I think it's the correct solution so as to keep interactive runs making sense. If the output _followed_ the result line in the spec-suggested YAML form, each test would dump all of its output at once instead of as it went, making debugging harder. This does, however, solve the recursive TAP output problem, as sub-tests will simply be prefixed by "# ". Parsing sub-tests becomes a simple problem of just removing the first two characters of a given top-level test's diagnostic output, and parsing the results. Note that the shell construct needed to both get an exit code from the first command in a pipe and still filter the pipe (to add the "# " prefix) uses a POSIX solution rather than the bash "pipefail" option which is not supported by dash. Since some test environments may have a very minimal set of utilities available, the new prefixing code will fall back to doing line-at-a-time prefixing if perl and/or stdbuf are not available. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-25selftests: Distinguish between missing and non-executableKees Cook1-1/+6
If a test was missing (e.g. wrong architecture, etc), the test runner would incorrectly claim the test was non-executable. This adds an existence check to report correctly. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-25selftests: Add plan line and fix result line syntaxKees Cook2-6/+8
The TAP version 13 spec requires a "plan" line, which has been missing. Since we always know how many tests we're going to run, emit the count on the plan line. This also fixes the result lines to remove the "1.." prefix which is against spec, and to mark skips with the correct "# SKIP" suffix. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-25selftests: Extract logic for multiple test runsKees Cook3-24/+32
This moves the logic for running multiple tests into a single "run_many" function of runner.sh. Both "run_tests" and "emit_tests" are modified to use it. Summary handling is now controlled by the "per_test_logging" shell flag. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-25selftests: Use runner.sh for emit targetsKees Cook2-19/+7
This reuses the new runner.sh for the emit targets instead of manually running each test via run_kselftest.sh. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-25selftests: Extract single-test shell logic from lib.mkKees Cook3-31/+39
In order to improve the reusability of the kselftest test running logic, this extracts the single-test logic from lib.mk into kselftest/runner.sh which lib.mk can call directly. No changes in output. As part of the change, this moves the "summary" Makefile logic around to set a new "logfile" output. This will be used again in the future "emit_tests" target as well. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-22selftests: build and run gpio when output directory is the src dirShuah Khan1-0/+9
Build and run gpio when output directory is the src dir. gpio has dependency on tools/gpio and builds tools/gpio objects in the src directory in all cases making the src repo dirty even when object relocation is specified. This fixes the following commands from generating gpio objects in the source repository: make O=dir kselftest export KBUILD_OUTPUT=dir; make kselftest make O=dir -C tools/testing/selftests expoert KBUILD_OUTPUT=dir; make -C tools/testing/selftests The following commands still build gpio objects in the source repo (gpio Makefile needs to fixed): make O=dir kselftest TARGETS="gpio" export KBUILD_OUTPUT=dir; make kselftest TARGETS="gpio" make O=dir -C tools/testing/selftests TARGETS="gpio" expoert KBUILD_OUTPUT=dir; make -C tools/testing/selftests TARGETS="gpio" Signed-off-by: Shuah Khan <[email protected]>
2019-04-19selftests/ipc: Fix msgque compiler warningsKees Cook1-5/+6
This fixes the various compiler warnings when building the msgque selftest. The primary change is using sys/msg.h instead of linux/msg.h directly to gain the API declarations. Fixes: 3a665531a3b7 ("selftests: IPC message queue copy feature test") Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-19selftests/efivarfs: clean up test files from test_create*()Po-Hsu Lin1-19/+13
Test files created by test_create() and test_create_empty() tests will stay in the $efivarfs_mount directory until the system was rebooted. When the tester tries to run this efivarfs test again on the same system, the immutable characteristics in that directory will cause some "Operation not permitted" noises, and a false-positve test result as the file was created in previous run. -------------------- running test_create -------------------- ./efivarfs.sh: line 59: /sys/firmware/efi/efivars/test_create-210be57c-9849-4fc7-a635-e6382d1aec27: Operation not permitted [PASS] -------------------- running test_create_empty -------------------- ./efivarfs.sh: line 78: /sys/firmware/efi/efivars/test_create_empty-210be57c-9849-4fc7-a635-e6382d1aec27: Operation not permitted [PASS] -------------------- Create a file_cleanup() to remove those test files in the end of each test to solve this issue. For the test_create_read, we can move the clean up task to the end of the test to ensure the system is clean. Also, use this function to replace the existing file removal code. Signed-off-by: Po-Hsu Lin <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-19selftests: fix headers_install circular dependencyShuah Khan2-10/+80
"make kselftest" fails with "Circular Makefile.o <- prepare dependency dropped." error, when lib.mk invokes "make headers_install". Make level 0: Main make calls selftests run_tests target ... Make level n: selftests lib.mk invokes main make's headers_install The secondary level make inherits builtin-rules which will use the rule to generate Makefile.o and runs into "Circular Makefile.o <- prepare dependency dropped." error, and kselftest compile fails. Invoke headers_install target with --no-builtin-rules to avoid circular error. In addition, lib.mk installs headers in the default HDR_PATH, even when build relocation is requested with O= or export KBUILD_OUTPUT. Fix the problem by passing in INSTALL_HDR_PATH. The headers are installed under the specified output "dir/usr". Signed-off-by: Shuah Khan <[email protected]>
2019-04-17selftests/kexec: update get_secureboot_modeMimi Zohar1-20/+66
The get_secureboot_mode() function unnecessarily requires both CONFIG_EFIVAR_FS and CONFIG_EFI_VARS to be enabled to determine if the system is booted in secure boot mode. On some systems the old EFI variable support is not enabled or, possibly, even implemented. This patch first checks the efivars filesystem for the SecureBoot and SetupMode flags, but falls back to using the old EFI variable support. The "secure_boot_file" and "setup_mode_file" couldn't be quoted due to globbing. This patch also removes the globbing. Signed-off-by: Mimi Zohar <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-17selftests/kexec: make kexec_load test independent of IMA being enabledMimi Zohar1-8/+16
Verify IMA is enabled before failing tests or emitting irrelevant messages. Suggested-by: Dave Young <[email protected]> Signed-off-by: Mimi Zohar <[email protected]> Reviewed-by: Dave Young <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-17selftests/kexec: check kexec_load and kexec_file_load are enabledMimi Zohar2-0/+13
Skip the kexec_load and kexec_file_load tests, if they aren't configured in the kernel. This change adds a new requirement that ikconfig is configured in the kexec_load test. Suggested-by: Dave Young <[email protected]> Signed-off-by: Mimi Zohar <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-17selftests/kexec: Add missing '=y' to config optionsPetr Vorel1-4/+3
so the file can be used as kernel config snippet. Signed-off-by: Petr Vorel <[email protected]> [[email protected]: remove CONFIG_KEXEC_VERIFY_SIG from config] Signed-off-by: Mimi Zohar <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-17selftests/kexec: kexec_file_load syscall testMimi Zohar4-3/+304
The kernel can be configured to verify PE signed kernel images, IMA kernel image signatures, both types of signatures, or none. This test verifies only properly signed kernel images are loaded into memory, based on the kernel configuration and runtime policies. Signed-off-by: Mimi Zohar <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-17selftests/kexec: define "require_root_privileges"Mimi Zohar2-3/+8
Many tests require root privileges. Define a common function. Suggested-by: Petr Vorel <[email protected]> Signed-off-by: Mimi Zohar <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-17selftests/kexec: define common logging functionsMimi Zohar2-14/+35
Define log_info, log_pass, log_fail, and log_skip functions. Suggested-by: Petr Vorel <[email protected]> Signed-off-by: Mimi Zohar <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-17selftests/kexec: define a set of common functionsMimi Zohar3-14/+42
Define, update and move get_secureboot_mode() to a common file for use by other tests. Updated to check both the efivar SecureBoot-$(UUID) and SetupMode-$(UUID), based on Dave Young's review. Signed-off-by: Mimi Zohar <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-17selftests/kexec: cleanup the kexec selftestMimi Zohar1-9/+9
Remove the few bashisms and use the complete option name for clarity. Signed-off-by: Mimi Zohar <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-17selftests/kexec: move the IMA kexec_load selftest to selftests/kexecMimi Zohar4-1/+1
As requested move the existing kexec_load selftest and subsequent kexec tests to the selftests/kexec directory. Suggested-by: Dave Young <[email protected]> Signed-off-by: Mimi Zohar <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-16selftests/harness: Add 30 second timeout per testKees Cook1-0/+2
In order to keep tests from hanging forever, this adds an alarm signal to each test run. This assumes an individual test doesn't take longer than 30 seconds. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-16selftests/seccomp: Handle namespace failures gracefullyKees Cook1-20/+23
When running without USERNS or PIDNS the seccomp test would hang since it was waiting forever for the child to trigger the user notification since it seems the glibc() abort handler makes a call to getpid(), which would trap again. This changes the getpid filter to getppid, and makes sure ASSERTs execute to stop from spawning the listener. Reported-by: Shuah Khan <[email protected]> Fixes: 6a21cc50f0c7 ("seccomp: add a return code to trap to userspace") Cc: [email protected] # > 5.0 Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Tycho Andersen <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-08selftests: cgroup: fix cleanup path in test_memcg_subtree_control()Roman Gushchin1-17/+21
Dan reported, that cleanup path in test_memcg_subtree_control() triggers a static checker warning: ./tools/testing/selftests/cgroup/test_memcontrol.c:76 \ test_memcg_subtree_control() error: uninitialized symbol 'child2'. Fix this by initializing child2 and parent2 variables and split the cleanup path into few stages. Signed-off-by: Roman Gushchin <[email protected]> Fixes: 84092dbcf901 ("selftests: cgroup: add memory controller self-tests") Reported-by: Dan Carpenter <[email protected]> Cc: Dan Carpenter <[email protected]> Cc: Shuah Khan (Samsung OSG) <[email protected]> Cc: Mike Rapoport <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-08selftests: efivarfs: remove the test_create_read file if it was existZhangXiaoxu1-0/+4
After the first run, the test case 'test_create_read' will always fail because the file is exist and file's attr is 'S_IMMUTABLE', open with 'O_RDWR' will always return -EPERM. Signed-off-by: ZhangXiaoxu <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-08rseq/selftests: Adapt number of threads to the number of detected cpusMathieu Desnoyers1-2/+5
On smaller systems, running a test with 200 threads can take a long time on machines with smaller number of CPUs. Detect the number of online cpus at test runtime, and multiply that by 6 to have 6 rseq threads per cpu preempting each other. Signed-off-by: Mathieu Desnoyers <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Joel Fernandes <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Dave Watson <[email protected]> Cc: Will Deacon <[email protected]> Cc: Andi Kleen <[email protected]> Cc: [email protected] Cc: "H . Peter Anvin" <[email protected]> Cc: Chris Lameter <[email protected]> Cc: Russell King <[email protected]> Cc: Michael Kerrisk <[email protected]> Cc: "Paul E . McKenney" <[email protected]> Cc: Paul Turner <[email protected]> Cc: Boqun Feng <[email protected]> Cc: Josh Triplett <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Ben Maurer <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Linus Torvalds <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-08lib: Add test module for strscpy_padTobin C. Harding3-1/+5
Add a test module for the new strscpy_pad() function. Tie it into the kselftest infrastructure for lib/ tests. Acked-by: Kees Cook <[email protected]> Signed-off-by: Tobin C. Harding <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-08kselftest: Add test module framework headerTobin C. Harding1-0/+48
kselftest runs as a userspace process. Sometimes we need to test things from kernel space. One way of doing this is by creating a test module. Currently doing so requires developers to write a bunch of boiler plate in the module if kselftest is to be used to run the tests. This means we currently have a load of duplicate code to achieve these ends. If we have a uniform method for implementing test modules then we can reduce code duplication, ensure uniformity in the test framework, ease code maintenance, and reduce the work required to create tests. This all helps to encourage developers to write and run tests. Add a C header file that can be included in test modules. This provides a single point for common test functions/macros. Implement a few macros that make up the start of the test framework. Add documentation for new kselftest header to kselftest documentation. Acked-by: Kees Cook <[email protected]> Signed-off-by: Tobin C. Harding <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-08kselftest: Add test runner creation scriptTobin C. Harding4-50/+88
Currently if we wish to use kselftest to run tests within a kernel module we write a small script to load/unload and do error reporting. There are a bunch of these under tools/testing/selftests/lib/ that are all identical except for the test name. We can reduce code duplication and improve maintainability if we have one version of this. However kselftest requires an executable for each test. We can move all the script logic to a central script then have each individual test script call the main script. Oneliner to call kselftest_module.sh courtesy of Kees, thanks! Add test runner creation script. Convert tools/testing/selftests/lib/*.sh to use new test creation script. Testing ------- Configure kselftests for lib/ then build and boot kernel. Then run kselftests as follows: $ cd /path/to/kernel/tree $ sudo make O=$output_path -C tools/testing/selftests TARGETS="lib" run_tests and also $ cd /path/to/kernel/tree $ cd tools/testing/selftests $ sudo make O=$output_path TARGETS="lib" run_tests and also $ cd /path/to/kernel/tree $ cd tools/testing/selftests $ sudo make TARGETS="lib" run_tests Acked-by: Kees Cook <[email protected]> Signed-off-by: Tobin C. Harding <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-08selftest/gpio: Remove duplicate headerSabyasachi Gupta1-1/+0
Remove duplicate header which are included twice. Signed-off-by: Sabyasachi Gupta <[email protected]> Signed-off-by: Souptick Joarder <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-08selftest/rseq: Remove duplicate headerSabyasachi Gupta1-1/+0
Remove duplicate header which is included twice Signed-off-by: Sabyasachi Gupta <[email protected]> Signed-off-by: Souptick Joarder <[email protected]> Acked-by: Mathieu Desnoyers <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-08selftest/timers: Remove duplicate headerSabyasachi Gupta1-1/+0
Remove duplicate header which is included twice. Signed-off-by: Sabyasachi Gupta <[email protected]> Signed-off-by: Souptick Joarder <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
2019-04-08selftest/x86/mpx-dig.c: Remove duplicate headerSabyasachi Gupta1-2/+0
Remove duplicate header which is included twice. Signed-off-by: Sabyasachi Gupta <[email protected]> Signed-off-by: Souptick Joarder <[email protected]> Signed-off-by: Shuah Khan <[email protected]>