]> www.infradead.org Git - users/hch/xfs.git/commit
selftests/exec: add a test for execveat()'s comm
authorTycho Andersen <tandersen@netflix.com>
Wed, 30 Oct 2024 20:37:32 +0000 (14:37 -0600)
committerKees Cook <kees@kernel.org>
Tue, 17 Dec 2024 00:55:02 +0000 (16:55 -0800)
commit184a9358e506b77ade22c07dda4f34d133bc31c0
tree54237a7a2e173bd08b96d588cfed37d48a385182
parent543841d1806029889c2f69f040e88b247aba8e22
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/
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>
tools/testing/selftests/exec/execveat.c