aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/exec
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2025-01-31 17:12:31 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2025-01-31 17:12:31 -0800
commitbdd4f86c97e60b748027bdf6f6a3729c8a12da15 (patch)
treed894b0a952029ae89b067921987202ea71f3f56e /tools/testing/selftests/exec
parentMerge tag 'hardening-v6.14-rc1-fix1' of git://git.kernel.org/pub/scm/linux/ke... (diff)
parentselftests: Handle old glibc without execveat(2) (diff)
downloadlinux-bdd4f86c97e60b748027bdf6f6a3729c8a12da15.tar.gz
linux-bdd4f86c97e60b748027bdf6f6a3729c8a12da15.zip
Merge tag 'AT_EXECVE_CHECK-v6.14-rc1-fix1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull AT_EXECVE_CHECK selftest fix from Kees Cook: "Fixes the AT_EXECVE_CHECK selftests which didn't run on old versions of glibc" * tag 'AT_EXECVE_CHECK-v6.14-rc1-fix1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: selftests: Handle old glibc without execveat(2)
Diffstat (limited to 'tools/testing/selftests/exec')
-rw-r--r--tools/testing/selftests/exec/check-exec.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/testing/selftests/exec/check-exec.c b/tools/testing/selftests/exec/check-exec.c
index 4d3f4525e1e1..55bce47e56b7 100644
--- a/tools/testing/selftests/exec/check-exec.c
+++ b/tools/testing/selftests/exec/check-exec.c
@@ -22,6 +22,7 @@
#include <sys/prctl.h>
#include <sys/socket.h>
#include <sys/stat.h>
+#include <sys/syscall.h>
#include <sys/sysmacros.h>
#include <unistd.h>
@@ -31,6 +32,12 @@
#include "../kselftest_harness.h"
+static int sys_execveat(int dirfd, const char *pathname, char *const argv[],
+ char *const envp[], int flags)
+{
+ return syscall(__NR_execveat, dirfd, pathname, argv, envp, flags);
+}
+
static void drop_privileges(struct __test_metadata *const _metadata)
{
const unsigned int noroot = SECBIT_NOROOT | SECBIT_NOROOT_LOCKED;
@@ -219,8 +226,8 @@ static void test_exec_fd(struct __test_metadata *_metadata, const int fd,
* test framework as an error. With AT_EXECVE_CHECK, we only check a
* potential successful execution.
*/
- access_ret =
- execveat(fd, "", argv, NULL, AT_EMPTY_PATH | AT_EXECVE_CHECK);
+ access_ret = sys_execveat(fd, "", argv, NULL,
+ AT_EMPTY_PATH | AT_EXECVE_CHECK);
access_errno = errno;
if (err_code) {
EXPECT_EQ(-1, access_ret);