hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/tools/testing/selftests/exec/execveat.c
....@@ -1,12 +1,13 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2014 Google, Inc.
3
- *
4
- * Licensed under the terms of the GNU GPL License version 2
54 *
65 * Selftests for execveat(2).
76 */
87
8
+#ifndef _GNU_SOURCE
99 #define _GNU_SOURCE /* to get O_PATH, AT_EMPTY_PATH */
10
+#endif
1011 #include <sys/sendfile.h>
1112 #include <sys/stat.h>
1213 #include <sys/syscall.h>
....@@ -312,6 +313,10 @@
312313 fail += check_execveat_fail(AT_FDCWD, fullname_symlink,
313314 AT_SYMLINK_NOFOLLOW, ELOOP);
314315
316
+ /* Non-regular file failure */
317
+ fail += check_execveat_fail(dot_dfd, "pipe", 0, EACCES);
318
+ unlink("pipe");
319
+
315320 /* Shell script wrapping executable file: */
316321 /* dfd + path */
317322 fail += check_execveat(subdir_dfd, "../script", 0);
....@@ -385,6 +390,8 @@
385390 fd = open("subdir.ephemeral/script", O_RDWR|O_CREAT|O_TRUNC, 0755);
386391 write(fd, script, strlen(script));
387392 close(fd);
393
+
394
+ mkfifo("pipe", 0755);
388395 }
389396
390397 int main(int argc, char **argv)