mirror-linux/tools/testing/selftests/exec
Tycho Andersen 184a9358e5 selftests/exec: add a test for execveat()'s comm
In the previous patch we've updated AT_EMPTY_PATH execs to use the dentry
filename. Test for this and just to be sure keeps working with symlinks,
which was a concern in [1], I've added a test for that as well.

The test itself is a bit ugly, because the existing check_execveat_fail()
helpers use a hardcoded envp and argv, and we want to "pass" things via the
environment to test various argument values, but it seemed cleaner than
passing one in everywhere in all the existing tests.

Output looks like:

    ok 51 Check success of execveat(6, 'home/tycho/packages/...yyyyyyyyyyyyyyyyyyyy', 0)...
    # Check execveat(AT_EMPTY_PATH)'s comm is execveat
    ok 52 Check success of execveat(9, '', 4096)...
    # Check execveat(AT_EMPTY_PATH)'s comm is execveat
    ok 53 Check success of execveat(11, '', 4096)...
    # Check execveat(AT_EMPTY_PATH)'s comm is execveat
    [   25.579272] process 'execveat' launched '/dev/fd/9' with NULL argv: empty string added
    ok 54 Check success of execveat(9, '', 4096)...

Link: https://lore.kernel.org/all/20240925.152228-private.conflict.frozen.trios-TdUGhuI5Sb4v@cyphar.com/ [1]
Signed-off-by: Tycho Andersen <tandersen@netflix.com>
Link: https://lore.kernel.org/r/20241030203732.248767-2-tycho@tycho.pizza
Signed-off-by: Kees Cook <kees@kernel.org>
2024-12-16 16:55:02 -08:00
..
.gitignore selftests: exec: update gitignore for load_address 2024-09-30 11:42:19 -06:00
Makefile - 875fa64577da ("mm/hugetlb_vmemmap: fix race with speculative PFN 2024-07-21 17:15:46 -07:00
binfmt_script.py selftests/exec: binfmt_script: Add the overall result line according to TAP 2024-03-13 11:53:45 -07:00
execveat.c selftests/exec: add a test for execveat()'s comm 2024-12-16 16:55:02 -08:00
load_address.c selftests/exec: Build both static and non-static load_address tests 2024-06-19 12:44:39 -07:00
non-regular.c selftests/exec: add file type errno tests 2020-08-14 19:56:56 -07:00
null-argv.c selftests/exec: Test for empty string on NULL argv 2022-03-01 16:16:27 -08:00
recursion-depth.c selftests: exec: Use new ksft_exit_fail_perror() helper 2024-05-06 13:57:19 -06:00