Hi, Willy
This v4 mainly uses the argv0 suggested by you, at the same time, a new run-libc-test target is added for glibc and musl, and the RB_ flags are added for nolibc to allow compile nolibc-test.c without <linux/reboot.h> for glibc, musl and nolibc (mainly for musl-gcc, without -I /path/to/sysroot).
This patchset is based on the 20230705-nolibc-series2 branch of nolibc repo [2], it must be applied after our v6 __sysret series [3] (argv0 exported there) and Thomas' chmod_net removal patchset [4] (the new chmod_argv0 is added at the same line of chmod_net, will conflict).
This patchset assumes the chmod_net removal patchset will be applied at first, if not, the chmod_argv0 added alphabetically will not be applied. Since our new chmod_argv0 is exactly added to replace chmod_net, so, Willy, is it ok for you to at least apply the chmod_net removal patch [5] before this patchset?
selftests/nolibc: drop test chmod_net
This patchset is tested together with the v6 __sysret series [3]:
arch/board | result ------------|------------ arm/vexpress-a9 | 142 test(s) passed, 1 skipped, 0 failed. arm/virt | 142 test(s) passed, 1 skipped, 0 failed. aarch64/virt | 142 test(s) passed, 1 skipped, 0 failed. ppc/g3beige | not supported ppc/ppce500 | not supported i386/pc | 142 test(s) passed, 1 skipped, 0 failed. x86_64/pc | 142 test(s) passed, 1 skipped, 0 failed. mipsel/malta | 142 test(s) passed, 1 skipped, 0 failed. loongarch64/virt | 142 test(s) passed, 1 skipped, 0 failed. riscv64/virt | 142 test(s) passed, 1 skipped, 0 failed. riscv32/virt | 0 test(s) passed, 0 skipped, 0 failed. s390x/s390-ccw-virtio | 142 test(s) passed, 1 skipped, 0 failed.
If use tinyconfig + basic console options (means disable all of the other options, include procfs, shmem, tmpfs, net and memfd_create, to save test time, only randomly choose 4 archs):
...
LOG: testing report for loongarch64/virt:
15 chmod_self [SKIPPED] 16 chown_self [SKIPPED] 40 link_cross [SKIPPED] 0 -fstackprotector not supported [SKIPPED]
139 test(s) passed, 4 skipped, 0 failed. See all results in /labs/linux-lab/logging/nolibc/loongarch64-virt-nolibc-test.log
LOG: testing summary:
arch/board | result ------------|------------ arm/vexpress-a9 | 139 test(s) passed, 4 skipped, 0 failed. x86_64/pc | 139 test(s) passed, 4 skipped, 0 failed. mipsel/malta | 139 test(s) passed, 4 skipped, 0 failed. loongarch64/virt | 139 test(s) passed, 4 skipped, 0 failed.
Changes from v3 --> v4:
* selftests/nolibc: stat_fault: silence NULL argument warning with glibc selftests/nolibc: gettid: restore for glibc and musl selftests/nolibc: add _LARGEFILE64_SOURCE for musl selftests/nolibc: fix up int_fast16/32_t test cases for musl selftests/nolibc: fix up kernel parameters support selftests/nolibc: link_cross: use /proc/self/cmdline tools/nolibc: add rmdir() support selftests/nolibc: add a new rmdir() test case selftests/nolibc: fix up failures when CONFIG_PROC_FS=n selftests/nolibc: prepare /tmp for tmpfs or ramfs selftests/nolibc: vfprintf: remove MEMFD_CREATE dependency
No change.
* selftests/nolibc: add run-libc-test target
New run and report for glibc or musl. for musl, we can simply issue:
$ make run-libc-test CC=/path/to/musl-install/bin/musl-gcc
* tools/nolibc: types.h: add RB_ flags for reboot() selftests/nolibc: prefer <sys/reboot.h> to <linux/reboot.h>
Required by musl to compile nolibc-test.c without -I/path/to/sysroot
* selftests/nolibc: chdir_root: restore current path after test
restore current path to prevent breakage of using relative path
* selftests/nolibc: stat_timestamps: remove procfs dependency selftests/nolibc: chroot_exe: remove procfs dependency selftests/nolibc: add chmod_argv0 test
use argv0 instead of '/init' as before.
Best regards, Zhangjin --- [1]: https://lore.kernel.org/lkml/cover.1688134399.git.falcon@tinylab.org/ [2]: https://git.kernel.org/pub/scm/linux/kernel/git/wtarreau/nolibc.git [3]: https://lore.kernel.org/lkml/cover.1688739492.git.falcon@tinylab.org/ [4]: https://lore.kernel.org/lkml/20230624-proc-net-setattr-v1-0-73176812adee@wei... [5]: https://lore.kernel.org/lkml/20230624-proc-net-setattr-v1-1-73176812adee@wei...
Zhangjin Wu (18): selftests/nolibc: add run-libc-test target selftests/nolibc: stat_fault: silence NULL argument warning with glibc selftests/nolibc: gettid: restore for glibc and musl selftests/nolibc: add _LARGEFILE64_SOURCE for musl selftests/nolibc: fix up int_fast16/32_t test cases for musl tools/nolibc: types.h: add RB_ flags for reboot() selftests/nolibc: prefer <sys/reboot.h> to <linux/reboot.h> selftests/nolibc: fix up kernel parameters support selftests/nolibc: link_cross: use /proc/self/cmdline tools/nolibc: add rmdir() support selftests/nolibc: add a new rmdir() test case selftests/nolibc: fix up failures when CONFIG_PROC_FS=n selftests/nolibc: prepare /tmp for tmpfs or ramfs selftests/nolibc: vfprintf: remove MEMFD_CREATE dependency selftests/nolibc: chdir_root: restore current path after test selftests/nolibc: stat_timestamps: remove procfs dependency selftests/nolibc: chroot_exe: remove procfs dependency selftests/nolibc: add chmod_argv0 test
tools/include/nolibc/sys.h | 23 ++++- tools/include/nolibc/types.h | 12 ++- tools/testing/selftests/nolibc/Makefile | 4 + tools/testing/selftests/nolibc/nolibc-test.c | 88 +++++++++++++++----- 4 files changed, 104 insertions(+), 23 deletions(-)
allow run and report glibc or musl based libc-test.
Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/Makefile | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 000621f21adc..d408b688b291 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -132,6 +132,10 @@ nolibc-test: nolibc-test.c sysroot/$(ARCH)/include libc-test: nolibc-test.c $(QUIET_CC)$(CC) -o $@ $<
+run-libc-test: libc-test + $(Q)./libc-test > "$(CURDIR)/run.out" || : + $(Q)$(REPORT) $(CURDIR)/run.out + # qemu user-land test run-user: nolibc-test $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || :
Use another invalid address (void *)1 instead of NULL to silence this compile warning with glibc:
$ make libc-test CC libc-test nolibc-test.c: In function ‘run_syscall’: nolibc-test.c:622:49: warning: null argument where non-null required (argument 1) [-Wnonnull] 622 | CASE_TEST(stat_fault); EXPECT_SYSER(1, stat(NULL, &stat_buf), -1, EFAULT); break; | ^~~~ nolibc-test.c:304:79: note: in definition of macro ‘EXPECT_SYSER2’ 304 | do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_syserr2(expr, expret, experr1, experr2, llen); } while (0) | ^~~~ nolibc-test.c:622:33: note: in expansion of macro ‘EXPECT_SYSER’ 622 | CASE_TEST(stat_fault); EXPECT_SYSER(1, stat(NULL, &stat_buf), -1, EFAULT); break;
Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 06c561c4b09d..b4b64125d418 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -742,7 +742,7 @@ int run_syscall(int min, int max) CASE_TEST(select_stdout); EXPECT_SYSNE(1, ({ fd_set fds; FD_ZERO(&fds); FD_SET(1, &fds); select(2, NULL, &fds, NULL, NULL); }), -1); break; CASE_TEST(select_fault); EXPECT_SYSER(1, select(1, (void *)1, NULL, NULL, 0), -1, EFAULT); break; CASE_TEST(stat_blah); EXPECT_SYSER(1, stat("/proc/self/blah", &stat_buf), -1, ENOENT); break; - CASE_TEST(stat_fault); EXPECT_SYSER(1, stat(NULL, &stat_buf), -1, EFAULT); break; + CASE_TEST(stat_fault); EXPECT_SYSER(1, stat((void *)1, &stat_buf), -1, EFAULT); break; CASE_TEST(stat_timestamps); EXPECT_SYSZR(1, test_stat_timestamps()); break; CASE_TEST(symlink_root); EXPECT_SYSER(1, symlink("/", "/"), -1, EEXIST); break; CASE_TEST(unlink_root); EXPECT_SYSER(1, unlink("/"), -1, EISDIR); break;
As the gettid manpage [1] shows, glibc 2.30 has gettid support, so, let's enable the test for glibc >= 2.30.
gettid works on musl too.
[1]: https://man7.org/linux/man-pages/man2/gettid.2.html
Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index b4b64125d418..b63afe1975c4 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -668,6 +668,7 @@ int run_syscall(int min, int max) int tmp; int ret = 0; void *p1, *p2; + int has_gettid = 1;
/* <proc> indicates whether or not /proc is mounted */ proc = stat("/proc", &stat_buf) == 0; @@ -675,6 +676,11 @@ int run_syscall(int min, int max) /* this will be used to skip certain tests that can't be run unprivileged */ euid0 = geteuid() == 0;
+ /* from 2.30, glibc provides gettid() */ +#if defined(__GLIBC_MINOR__) && defined(__GLIBC__) + has_gettid = __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 30); +#endif + for (test = min; test >= 0 && test <= max; test++) { int llen = 0; /* line length */
@@ -684,9 +690,7 @@ int run_syscall(int min, int max) switch (test + __LINE__ + 1) { CASE_TEST(getpid); EXPECT_SYSNE(1, getpid(), -1); break; CASE_TEST(getppid); EXPECT_SYSNE(1, getppid(), -1); break; -#ifdef NOLIBC - CASE_TEST(gettid); EXPECT_SYSNE(1, gettid(), -1); break; -#endif + CASE_TEST(gettid); EXPECT_SYSNE(has_gettid, gettid(), -1); break; CASE_TEST(getpgid_self); EXPECT_SYSNE(1, getpgid(0), -1); break; CASE_TEST(getpgid_bad); EXPECT_SYSER(1, getpgid(-1), -1, ESRCH); break; CASE_TEST(kill_0); EXPECT_SYSZR(1, kill(getpid(), 0)); break;
_GNU_SOURCE Implies _LARGEFILE64_SOURCE in glibc, but in musl, the default configuration doesn't enable _LARGEFILE64_SOURCE.
From include/dirent.h of musl, getdents64 is provided as getdents when _LARGEFILE64_SOURCE is defined.
#if defined(_LARGEFILE64_SOURCE) ... #define getdents64 getdents #endif
Let's define _LARGEFILE64_SOURCE to fix up this compile error:
tools/testing/selftests/nolibc/nolibc-test.c: In function ‘test_getdents64’: tools/testing/selftests/nolibc/nolibc-test.c:453:8: warning: implicit declaration of function ‘getdents64’; did you mean ‘getdents’? [-Wimplicit-function-declaration] 453 | ret = getdents64(fd, (void *)buffer, sizeof(buffer)); | ^~~~~~~~~~ | getdents /usr/bin/ld: /tmp/ccKILm5u.o: in function `test_getdents64': nolibc-test.c:(.text+0xe3e): undefined reference to `getdents64' collect2: error: ld returned 1 exit status
Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index b63afe1975c4..db743144d8f3 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */
#define _GNU_SOURCE +#define _LARGEFILE64_SOURCE
/* libc-specific include files * The program may be built in 3 ways:
musl limits the fast signed int in 32bit, but glibc and nolibc don't, to let such test cases work on musl, let's provide the type based SINT_MAX_OF_TYPE(type) and SINT_MIN_OF_TYPE(type).
Suggested-by: Thomas Weißschuh linux@weissschuh.net Link: https://lore.kernel.org/lkml/bc635c4f-67fe-4e86-bfdf-bcb4879b928d@t-8ch.de/ Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index db743144d8f3..fea1b06131f6 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -41,6 +41,10 @@ #endif #endif
+/* for the type of int_fast16_t and int_fast32_t, musl differs from glibc and nolibc */ +#define SINT_MAX_OF_TYPE(type) (((type)1 << (sizeof(type) * 8 - 2)) - (type)1 + ((type)1 << (sizeof(type) * 8 - 2))) +#define SINT_MIN_OF_TYPE(type) (-SINT_MAX_OF_TYPE(type) - 1) + /* will be used by nolibc by getenv() */ char **environ;
@@ -827,11 +831,11 @@ int run_stdlib(int min, int max) CASE_TEST(limit_int_fast8_max); EXPECT_EQ(1, INT_FAST8_MAX, (int_fast8_t) 0x7f); break; CASE_TEST(limit_int_fast8_min); EXPECT_EQ(1, INT_FAST8_MIN, (int_fast8_t) 0x80); break; CASE_TEST(limit_uint_fast8_max); EXPECT_EQ(1, UINT_FAST8_MAX, (uint_fast8_t) 0xff); break; - CASE_TEST(limit_int_fast16_min); EXPECT_EQ(1, INT_FAST16_MIN, (int_fast16_t) INTPTR_MIN); break; - CASE_TEST(limit_int_fast16_max); EXPECT_EQ(1, INT_FAST16_MAX, (int_fast16_t) INTPTR_MAX); break; + CASE_TEST(limit_int_fast16_min); EXPECT_EQ(1, INT_FAST16_MIN, (int_fast16_t) SINT_MIN_OF_TYPE(int_fast16_t)); break; + CASE_TEST(limit_int_fast16_max); EXPECT_EQ(1, INT_FAST16_MAX, (int_fast16_t) SINT_MAX_OF_TYPE(int_fast16_t)); break; CASE_TEST(limit_uint_fast16_max); EXPECT_EQ(1, UINT_FAST16_MAX, (uint_fast16_t) UINTPTR_MAX); break; - CASE_TEST(limit_int_fast32_min); EXPECT_EQ(1, INT_FAST32_MIN, (int_fast32_t) INTPTR_MIN); break; - CASE_TEST(limit_int_fast32_max); EXPECT_EQ(1, INT_FAST32_MAX, (int_fast32_t) INTPTR_MAX); break; + CASE_TEST(limit_int_fast32_min); EXPECT_EQ(1, INT_FAST32_MIN, (int_fast32_t) SINT_MIN_OF_TYPE(int_fast32_t)); break; + CASE_TEST(limit_int_fast32_max); EXPECT_EQ(1, INT_FAST32_MAX, (int_fast32_t) SINT_MAX_OF_TYPE(int_fast32_t)); break; CASE_TEST(limit_uint_fast32_max); EXPECT_EQ(1, UINT_FAST32_MAX, (uint_fast32_t) UINTPTR_MAX); break; CASE_TEST(limit_int_fast64_min); EXPECT_EQ(1, INT_FAST64_MIN, (int_fast64_t) INT64_MIN); break; CASE_TEST(limit_int_fast64_max); EXPECT_EQ(1, INT_FAST64_MAX, (int_fast64_t) INT64_MAX); break;
Both glibc and musl provide RB_ flags via <sys/reboot.h> for reboot(), they don't need to include <linux/reboot.h>, let nolibc provide RB_ flags too.
Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/include/nolibc/sys.h | 1 - tools/include/nolibc/types.h | 12 +++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 61a3204b00d7..804bc0231ec7 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -21,7 +21,6 @@ #include <linux/auxvec.h> #include <linux/fcntl.h> /* for O_* and AT_* */ #include <linux/stat.h> /* for statx() */ -#include <linux/reboot.h> /* for LINUX_REBOOT_* */ #include <linux/prctl.h>
#include "arch.h" diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 5e1bac8509ec..23963e48d8ee 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -9,8 +9,9 @@
#include "std.h" #include <linux/mman.h> -#include <linux/time.h> +#include <linux/reboot.h> /* for LINUX_REBOOT_* */ #include <linux/stat.h> +#include <linux/time.h>
/* Only the generic macros and types may be defined here. The arch-specific @@ -92,6 +93,15 @@ #define SEEK_CUR 1 #define SEEK_END 2
+/* flags for reboot */ +#define RB_AUTOBOOT LINUX_REBOOT_CMD_RESTART +#define RB_HALT_SYSTEM LINUX_REBOOT_CMD_HALT +#define RB_ENABLE_CAD LINUX_REBOOT_CMD_CAD_ON +#define RB_DISABLE_CAD LINUX_REBOOT_CMD_CAD_OFF +#define RB_POWER_OFF LINUX_REBOOT_CMD_POWER_OFF +#define RB_SW_SUSPEND LINUX_REBOOT_CMD_SW_SUSPEND +#define RB_KEXEC LINUX_REBOOT_CMD_KEXEC + /* Macros used on waitpid()'s return status */ #define WEXITSTATUS(status) (((status) & 0xff00) >> 8) #define WIFEXITED(status) (((status) & 0x7f) == 0)
Since both glibc and musl provide RB_ flags via <sys/reboot.h>, and we just add RB_ flags for nolibc, let's use RB_ flags instead of LINUX_REBOOT_ flags and only reserve the required <sys/reboot.h> header.
This allows compile libc-test for musl libc without the linux headers.
Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index fea1b06131f6..12ecae85403e 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -15,7 +15,6 @@ #include <string.h> #ifndef _NOLIBC_STDIO_H /* standard libcs need more includes */ -#include <linux/reboot.h> #include <sys/io.h> #include <sys/ioctl.h> #include <sys/mman.h> @@ -1180,7 +1179,7 @@ int main(int argc, char **argv, char **envp) */ printf("Leaving init with final status: %d\n", !!ret); if (ret == 0) - reboot(LINUX_REBOOT_CMD_POWER_OFF); + reboot(RB_POWER_OFF); #if defined(__x86_64__) /* QEMU started with "-device isa-debug-exit -no-reboot" will * exit with status code 2N+1 when N is written to 0x501. We
kernel parameters allow pass two types of strings, one type is like 'noapic', another type is like 'panic=5', the first type is passed as arguments of the init program, the second type is passed as environment variables of the init program.
when users pass kernel parameters like this:
noapic NOLIBC_TEST=syscall
our nolibc-test program will use the test setting from argv[1] and ignore the one from NOLIBC_TEST environment variable, and at last, it will print the following line and ignore the whole test setting.
Ignoring unknown test name 'noapic'
reversing the parsing order does solve the above issue:
test = getenv("NOLIBC_TEST"); if (test) test = argv[1];
but it still doesn't work with such kernel parameters (without NOLIBC_TEST environment variable):
noapic FOO=bar
To support all of the potential kernel parameters, let's verify the test setting from both of argv[1] and NOLIBC_TEST environment variable.
Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 33 ++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 12ecae85403e..319cd51eff01 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1072,6 +1072,35 @@ static const struct test test_names[] = { { 0 } };
+int is_setting_valid(char *test) +{ + int idx, len, test_len, valid = 0; + char delimiter; + + if (!test) + return valid; + + test_len = strlen(test); + + for (idx = 0; test_names[idx].name; idx++) { + len = strlen(test_names[idx].name); + if (test_len < len) + continue; + + if (strncmp(test, test_names[idx].name, len) != 0) + continue; + + delimiter = test[len]; + if (delimiter != ':' && delimiter != ',' && delimiter != '\0') + continue; + + valid = 1; + break; + } + + return valid; +} + int main(int argc, char **argv, char **envp) { int min = 0; @@ -1098,10 +1127,10 @@ int main(int argc, char **argv, char **envp) * syscall:5-15[:.*],stdlib:8-10 */ test = argv[1]; - if (!test) + if (!is_setting_valid(test)) test = getenv("NOLIBC_TEST");
- if (test) { + if (is_setting_valid(test)) { char *comma, *colon, *dash, *value;
do {
For CONFIG_NET=n, there would be no /proc/self/net, so, use /proc/self/cmdline instead.
Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 319cd51eff01..cf38df6e036c 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -731,7 +731,7 @@ int run_syscall(int min, int max) CASE_TEST(link_root1); EXPECT_SYSER(1, link("/", "/"), -1, EEXIST); break; CASE_TEST(link_blah); EXPECT_SYSER(1, link("/proc/self/blah", "/blah"), -1, ENOENT); break; CASE_TEST(link_dir); EXPECT_SYSER(euid0, link("/", "/blah"), -1, EPERM); break; - CASE_TEST(link_cross); EXPECT_SYSER(proc, link("/proc/self/net", "/blah"), -1, EXDEV); break; + CASE_TEST(link_cross); EXPECT_SYSER(proc, link("/proc/self/cmdline", "/blah"), -1, EXDEV); break; CASE_TEST(lseek_m1); EXPECT_SYSER(1, lseek(-1, 0, SEEK_SET), -1, EBADF); break; CASE_TEST(lseek_0); EXPECT_SYSER(1, lseek(0, 0, SEEK_SET), -1, ESPIPE); break; CASE_TEST(mkdir_root); EXPECT_SYSER(1, mkdir("/", 0755), -1, EEXIST); break;
a reverse operation of mkdir() is meaningful, add rmdir() here.
required by nolibc-test to remove /proc while CONFIG_PROC_FS is not enabled.
Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/include/nolibc/sys.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 804bc0231ec7..dee56894a811 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -611,6 +611,28 @@ int mkdir(const char *path, mode_t mode) return __sysret(sys_mkdir(path, mode)); }
+/* + * int rmdir(const char *path); + */ + +static __attribute__((unused)) +int sys_rmdir(const char *path) +{ +#ifdef __NR_rmdir + return my_syscall1(__NR_rmdir, path); +#elif defined(__NR_unlinkat) + return my_syscall3(__NR_unlinkat, AT_FDCWD, path, AT_REMOVEDIR); +#else + return -ENOSYS; +#endif +} + +static __attribute__((unused)) +int rmdir(const char *path) +{ + return __sysret(sys_rmdir(path)); +} +
/* * int mknod(const char *path, mode_t mode, dev_t dev);
A new rmdir_blah test case is added to remove a non-existing /blah, which expects failure with ENOENT errno.
Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index cf38df6e036c..deff804e0753 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -745,6 +745,7 @@ int run_syscall(int min, int max) CASE_TEST(poll_fault); EXPECT_SYSER(1, poll((void *)1, 1, 0), -1, EFAULT); break; CASE_TEST(prctl); EXPECT_SYSER(1, prctl(PR_SET_NAME, (unsigned long)NULL, 0, 0, 0), -1, EFAULT); break; CASE_TEST(read_badf); EXPECT_SYSER(1, read(-1, &tmp, 1), -1, EBADF); break; + CASE_TEST(rmdir_blah); EXPECT_SYSER(1, rmdir("/blah"), -1, ENOENT); break; CASE_TEST(sched_yield); EXPECT_SYSZR(1, sched_yield()); break; CASE_TEST(select_null); EXPECT_SYSZR(1, ({ struct timeval tv = { 0 }; select(0, NULL, NULL, NULL, &tv); })); break; CASE_TEST(select_stdout); EXPECT_SYSNE(1, ({ fd_set fds; FD_ZERO(&fds); FD_SET(1, &fds); select(2, NULL, &fds, NULL, NULL); }), -1); break;
For CONFIG_PROC_FS=n, the /proc is not mountable, but the /proc directory has been created in the prepare() stage whenever /proc is there or not.
so, the checking of /proc in the run_syscall() stage will be always true and at last it will fail all of the procfs dependent test cases, which deviates from the 'cond' check design of the EXPECT_xx macros, without procfs, these test cases should be skipped instead of failed.
To solve this issue, one method is checking /proc/self instead of /proc, another method is removing the /proc directory completely for CONFIG_PROC_FS=n, we apply the second method to avoid misleading the users.
Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index deff804e0753..5497ee86cf40 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1056,8 +1056,11 @@ int prepare(void)
/* try to mount /proc if not mounted. Silently fail otherwise */ if (stat("/proc/.", &stat_buf) == 0 || mkdir("/proc", 0755) == 0) { - if (stat("/proc/self", &stat_buf) != 0) - mount("/proc", "/proc", "proc", 0, 0); + if (stat("/proc/self", &stat_buf) != 0) { + /* If not mountable, remove /proc completely to avoid misuse */ + if (mount("none", "/proc", "proc", 0, 0) != 0) + rmdir("/proc"); + } }
return 0;
create a /tmp directory and mount tmpfs there, if tmpfs is not mountable, use ramfs as tmpfs.
tmpfs will be used instead of procfs for some tests.
Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 5497ee86cf40..6b863f7b677c 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1063,6 +1063,10 @@ int prepare(void) } }
+ /* try to mount /tmp if not mounted, if not mountable, use ramfs as tmpfs */ + mkdir("/tmp", 0755); + mount("none", "/tmp", "tmpfs", 0, 0); + return 0; }
Hi Zhangjin,
On Sat, Jul 08, 2023 at 02:38:57AM +0800, Zhangjin Wu wrote:
create a /tmp directory and mount tmpfs there, if tmpfs is not mountable, use ramfs as tmpfs.
tmpfs will be used instead of procfs for some tests.
Just curious, in which cases do you need this ? We're building an initramfs for the root that's already read-write, so without mounting anything you already have write access. I'm taking it anyway for now, but if you figure it's not needed we can later drop it (or just drop the mount part and keep mkdir).
Willy
Hi, Willy
Hi Zhangjin,
On Sat, Jul 08, 2023 at 02:38:57AM +0800, Zhangjin Wu wrote:
create a /tmp directory and mount tmpfs there, if tmpfs is not mountable, use ramfs as tmpfs.
tmpfs will be used instead of procfs for some tests.
Just curious, in which cases do you need this ? We're building an initramfs for the root that's already read-write, so without mounting anything you already have write access. I'm taking it anyway for now, but if you figure it's not needed we can later drop it (or just drop the mount part and keep mkdir).
This "/tmp" directory is originally created to check the 'TMPFS' existence for the old vfprintf/memfd_create (from old version of the minimal config support), it is used to skip the whole vfprintf tests if the TMPFS (or HUGETLBFS) is not there. BTW, Thomas's patch [1] shows, MEMFD_CREATE is able to work with ramfs too.
And it is later used by the old chmod_tmpdir/chmod_tmpfile and chroot_tmpfile too (from old version of the minimal config support), so, it is important to align with the normal Linux systems to let "/tmp" means TMPFS mount.
Now, we use "/tmp" directly in vfprintf, and we use argv0 for chmod_exe and chroot_exe, so, the only user of "/tmp" is vfprintf currently. In this case, it is a simple normal writable directory to allow create tmp files there, so, agree very much to only reserve the mkdir part:
/* create /tmp if not there. Silently fail otherwise */ mkdir("/tmp", 0755);
Another consideration before is whether it is required to be consistent with the normal Linux systems, let the "/tmp" directory mounted as tmpfs at most of the time, but "/tmp" means ramfs for CONFIG_TMPFS=n currently even mount it explicitly (ramfs is a fallback of tmpfs in such case), so, this assumption of "/tmp" means tmpfs is not true currently.
What I'm worried about is people in the future assume "/tmp" as tmpfs at the first glance and use the features only provided by TMPFS but not provided by RAMFS (I'm not sure which one they will use). so, I even tried to create a "/tmp/tmpfs" flag for TMPFS and "/tmp/ramfs" flag for RAMFS before, since there is no user to explicitly prefer TMPFS to RAMFS currently, at last, I removed these flags from the sent patchsets. Based on the same logic, The removal of tmpfs mount is of course ok.
So, Willy, is it ok for you to remove that mount line with corresponding update of the commit message (and the subject title), or require me to send a revision for this patch?
Best regards, Zhangjin
--- [1]: https://lore.kernel.org/lkml/20230703224803.GF4378@monkey/
Willy
Hi Zhangjin,
On Mon, Jul 10, 2023 at 01:06:00PM +0800, Zhangjin Wu wrote:
On Sat, Jul 08, 2023 at 02:38:57AM +0800, Zhangjin Wu wrote:
create a /tmp directory and mount tmpfs there, if tmpfs is not mountable, use ramfs as tmpfs.
tmpfs will be used instead of procfs for some tests.
Just curious, in which cases do you need this ? We're building an initramfs for the root that's already read-write, so without mounting anything you already have write access. I'm taking it anyway for now, but if you figure it's not needed we can later drop it (or just drop the mount part and keep mkdir).
This "/tmp" directory is originally created to check the 'TMPFS' existence for the old vfprintf/memfd_create (from old version of the minimal config support), it is used to skip the whole vfprintf tests if the TMPFS (or HUGETLBFS) is not there. BTW, Thomas's patch [1] shows, MEMFD_CREATE is able to work with ramfs too.
OK but here we're neither using it nor even checking its success.
And it is later used by the old chmod_tmpdir/chmod_tmpfile and chroot_tmpfile too (from old version of the minimal config support), so, it is important to align with the normal Linux systems to let "/tmp" means TMPFS mount.
I think I didn't explain myself well. I'm not contesting a writable /tmp, I was asking why *tmpfs*, because we have a root on ramfs by default, so when you create /tmp, the sole fact that it succeeds implies that whatever you'll put into it will already work without having to remount a tmpfs inside.
Now, we use "/tmp" directly in vfprintf, and we use argv0 for chmod_exe and chroot_exe, so, the only user of "/tmp" is vfprintf currently. In this case, it is a simple normal writable directory to allow create tmp files there, so, agree very much to only reserve the mkdir part:
/* create /tmp if not there. Silently fail otherwise */ mkdir("/tmp", 0755);
OK, then I'll do that.
Another consideration before is whether it is required to be consistent with the normal Linux systems, let the "/tmp" directory mounted as tmpfs at most of the time,
That's not what I'm seeing on most of the systems I'm having access to, where /tmp is on a plain file system (either / or link to /var/tmp but always on disk, likely due to the huge size of the stuff stored there that is rarely used and that should not eat memory).
but "/tmp" means ramfs for CONFIG_TMPFS=n currently even mount it explicitly (ramfs is a fallback of tmpfs in such case), so, this assumption of "/tmp" means tmpfs is not true currently.
What I'm worried about is people in the future assume "/tmp" as tmpfs at the first glance and use the features only provided by TMPFS but not provided by RAMFS (I'm not sure which one they will use). so, I even tried to create a "/tmp/tmpfs" flag for TMPFS and "/tmp/ramfs" flag for RAMFS before, since there is no user to explicitly prefer TMPFS to RAMFS currently, at last, I removed these flags from the sent patchsets. Based on the same logic, The removal of tmpfs mount is of course ok.
Indeed, and also, please keep in mind what the purpose of nolibc-test is: make sure that the syscalls wrappers we write do work as expected, in part by allowing us to compare against another libc to figure whether it's the libc, the test or the kernel that causes any difference. The rest is purely out of scope. Thus it's not this test's business to verify that a tmpfs is indeed present after trying to mount it under /tmp, however it's this test business to make sure that options passed to mount() do work as expected, and that when a writable area is needed for a test, a working one is assigned. Thus for the specific case you mention, we don't care. And I'd go further, there can and should be reasonable prerequisites to run this test.
So, Willy, is it ok for you to remove that mount line with corresponding update of the commit message (and the subject title), or require me to send a revision for this patch?
No worries, I've modified it accordingly with the following commit message, just let me know if you want to change anything:
commit 11fddb386bd663a554cc08c5950d9da2c87a7267 (HEAD) Author: Zhangjin Wu falcon@tinylab.org Date: Sat Jul 8 02:38:57 2023 +0800
selftests/nolibc: prepare /tmp for tests that need to write
create a /tmp directory. If it succeeds, the directory is writable, which is normally the case when booted from an initramfs anyway.
This will be used instead of procfs for some tests.
Reviewed-by: Thomas WeiÃschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org Link: https://lore.kernel.org/lkml/20230710050600.9697-1-falcon@tinylab.org/ [wt: removed the unneeded mount() call] Signed-off-by: Willy Tarreau w@1wt.eu
Thanks! Willy
Hi, Willy
Hi Zhangjin,
On Mon, Jul 10, 2023 at 01:06:00PM +0800, Zhangjin Wu wrote:
On Sat, Jul 08, 2023 at 02:38:57AM +0800, Zhangjin Wu wrote:
[...]
Now, we use "/tmp" directly in vfprintf, and we use argv0 for chmod_exe and chroot_exe, so, the only user of "/tmp" is vfprintf currently. In this case, it is a simple normal writable directory to allow create tmp files there, so, agree very much to only reserve the mkdir part:
/* create /tmp if not there. Silently fail otherwise */ mkdir("/tmp", 0755);
OK, then I'll do that.
Thanks.
Another consideration before is whether it is required to be consistent with the normal Linux systems, let the "/tmp" directory mounted as tmpfs at most of the time,
That's not what I'm seeing on most of the systems I'm having access to, where /tmp is on a plain file system (either / or link to /var/tmp but always on disk, likely due to the huge size of the stuff stored there that is rarely used and that should not eat memory).
but "/tmp" means ramfs for CONFIG_TMPFS=n currently even mount it explicitly (ramfs is a fallback of tmpfs in such case), so, this assumption of "/tmp" means tmpfs is not true currently.
What I'm worried about is people in the future assume "/tmp" as tmpfs at the first glance and use the features only provided by TMPFS but not provided by RAMFS (I'm not sure which one they will use). so, I even tried to create a "/tmp/tmpfs" flag for TMPFS and "/tmp/ramfs" flag for RAMFS before, since there is no user to explicitly prefer TMPFS to RAMFS currently, at last, I removed these flags from the sent patchsets. Based on the same logic, The removal of tmpfs mount is of course ok.
Indeed, and also, please keep in mind what the purpose of nolibc-test is: make sure that the syscalls wrappers we write do work as expected, in part by allowing us to compare against another libc to figure whether it's the libc, the test or the kernel that causes any difference. The rest is purely out of scope. Thus it's not this test's business to verify that a tmpfs is indeed present after trying to mount it under /tmp, however it's this test business to make sure that options passed to mount() do work as expected, and that when a writable area is needed for a test, a working one is assigned. Thus for the specific case you mention, we don't care. And I'd go further, there can and should be reasonable prerequisites to run this test.
Ok.
So, Willy, is it ok for you to remove that mount line with corresponding update of the commit message (and the subject title), or require me to send a revision for this patch?
No worries, I've modified it accordingly with the following commit message, just let me know if you want to change anything:
commit 11fddb386bd663a554cc08c5950d9da2c87a7267 (HEAD) Author: Zhangjin Wu falcon@tinylab.org Date: Sat Jul 8 02:38:57 2023 +0800
selftests/nolibc: prepare /tmp for tests that need to write
create a /tmp directory. If it succeeds, the directory is writable, which is normally the case when booted from an initramfs anyway. This will be used instead of procfs for some tests. Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org Link: https://lore.kernel.org/lkml/20230710050600.9697-1-falcon@tinylab.org/ [wt: removed the unneeded mount() call] Signed-off-by: Willy Tarreau w@1wt.eu
Perfectly, Thanks a lot.
Best regards, Zhangjin
Thanks! Willy
The vfprintf test case require to open a temporary file to write, the old memfd_create() method is perfect but has strong dependency on MEMFD_CREATE and also TMPFS or HUGETLBFS (see fs/Kconfig):
config MEMFD_CREATE def_bool TMPFS || HUGETLBFS
And from v6.2, MFD_NOEXEC_SEAL must be passed for the non-executable memfd, otherwise, The kernel warning will be output to the test result like this:
Running test 'vfprintf' 0 emptymemfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL, pid=1 'init' "" = "" [OK]
To avoid such warning and also to remove the MEMFD_CREATE dependency, let's open a file from tmpfs directly.
The /tmp directory is used to detect the existing of tmpfs, if not there, skip instead of fail.
And further, for pid == 1, the initramfs is loaded as ramfs, which can be used as tmpfs, so, it is able to further remove TMPFS dependency too.
Suggested-by: Thomas Weißschuh linux@weissschuh.net Link: https://lore.kernel.org/lkml/9ad51430-b7c0-47dc-80af-20c86539498d@t-8ch.de Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 6b863f7b677c..494195890e4b 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -875,10 +875,10 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char FILE *memfile; va_list args;
- fd = memfd_create("vfprintf", 0); + fd = open("/tmp", O_TMPFILE | O_EXCL | O_RDWR, 0600); if (fd == -1) { - pad_spc(llen, 64, "[FAIL]\n"); - return 1; + pad_spc(llen, 64, "[SKIPPED]\n"); + return 0; }
memfile = fdopen(fd, "w+");
The PWD environment variable has the path of the nolibc-test program, the current path must be the same as it, otherwise, the test cases will fail with relative path (e.g. ./nolibc-test).
Since only chdir_root really changes the current path, let's restore it with the PWD environment variable.
Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 494195890e4b..0ed207495ea6 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -703,7 +703,7 @@ int run_syscall(int min, int max) CASE_TEST(sbrk_0); EXPECT_PTRNE(1, sbrk(0), (void *)-1); break; CASE_TEST(sbrk); if ((p1 = p2 = sbrk(4096)) != (void *)-1) p2 = sbrk(-4096); EXPECT_SYSZR(1, (p2 == (void *)-1) || p2 == p1); break; CASE_TEST(brk); EXPECT_SYSZR(1, brk(sbrk(0))); break; - CASE_TEST(chdir_root); EXPECT_SYSZR(1, chdir("/")); break; + CASE_TEST(chdir_root); EXPECT_SYSZR(1, chdir("/")); chdir(getenv("PWD")); break; CASE_TEST(chdir_dot); EXPECT_SYSZR(1, chdir(".")); break; CASE_TEST(chdir_blah); EXPECT_SYSER(1, chdir("/blah"), -1, ENOENT); break; CASE_TEST(chmod_self); EXPECT_SYSER(proc, chmod("/proc/self", 0555), -1, EPERM); break;
'/proc/self/' is a good path which doesn't have stale time info but it is only available for CONFIG_PROC_FS=y.
When CONFIG_PROC_FS=n, use argv0 instead of '/proc/self', use '/' for the worst case.
Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 0ed207495ea6..2065b5b0d171 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -584,7 +584,7 @@ static int test_stat_timestamps(void) if (sizeof(st.st_atim.tv_sec) != sizeof(st.st_atime)) return 1;
- if (stat("/proc/self/", &st)) + if (stat("/proc/self/", &st) && stat(argv0, &st) && stat("/", &st)) return 1;
if (st.st_atim.tv_sec != st.st_atime || st.st_atim.tv_nsec > 1000000000)
Since argv0 also works for CONFIG_PROC_FS=n, let's use it instead of '/proc/self/exe'.
Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 2065b5b0d171..c74b2af2414e 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -710,7 +710,7 @@ int run_syscall(int min, int max) CASE_TEST(chown_self); EXPECT_SYSER(proc, chown("/proc/self", 0, 0), -1, EPERM); break; CASE_TEST(chroot_root); EXPECT_SYSZR(euid0, chroot("/")); break; CASE_TEST(chroot_blah); EXPECT_SYSER(1, chroot("/proc/self/blah"), -1, ENOENT); break; - CASE_TEST(chroot_exe); EXPECT_SYSER(proc, chroot("/proc/self/exe"), -1, ENOTDIR); break; + CASE_TEST(chroot_exe); EXPECT_SYSER(1, chroot(argv0), -1, ENOTDIR); break; CASE_TEST(close_m1); EXPECT_SYSER(1, close(-1), -1, EBADF); break; CASE_TEST(close_dup); EXPECT_SYSZR(1, close(dup(0))); break; CASE_TEST(dup_0); tmp = dup(0); EXPECT_SYSNE(1, tmp, -1); close(tmp); break;
argv0 is readable and chmodable, let's use it for chmod test, but a safe umask should be used, the readable and executable modes should be reserved.
Reviewed-by: Thomas Weißschuh linux@weissschuh.net Signed-off-by: Zhangjin Wu falcon@tinylab.org --- tools/testing/selftests/nolibc/nolibc-test.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index c74b2af2414e..10247fbbdace 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -706,6 +706,7 @@ int run_syscall(int min, int max) CASE_TEST(chdir_root); EXPECT_SYSZR(1, chdir("/")); chdir(getenv("PWD")); break; CASE_TEST(chdir_dot); EXPECT_SYSZR(1, chdir(".")); break; CASE_TEST(chdir_blah); EXPECT_SYSER(1, chdir("/blah"), -1, ENOENT); break; + CASE_TEST(chmod_argv0); EXPECT_SYSZR(1, chmod(argv0, 0555)); break; CASE_TEST(chmod_self); EXPECT_SYSER(proc, chmod("/proc/self", 0555), -1, EPERM); break; CASE_TEST(chown_self); EXPECT_SYSER(proc, chown("/proc/self", 0, 0), -1, EPERM); break; CASE_TEST(chroot_root); EXPECT_SYSZR(euid0, chroot("/")); break;
Hi Zhangjin,
On Sat, Jul 08, 2023 at 02:21:20AM +0800, Zhangjin Wu wrote:
This patchset assumes the chmod_net removal patchset will be applied at first, if not, the chmod_argv0 added alphabetically will not be applied. Since our new chmod_argv0 is exactly added to replace chmod_net, so, Willy, is it ok for you to at least apply the chmod_net removal patch [5] before this patchset?
Sure, and thanks for the reminder, I had missed it in the middle of the flood.
(...)
LOG: testing summary: arch/board | result ------------|------------ arm/vexpress-a9 | 139 test(s) passed, 4 skipped, 0 failed. x86_64/pc | 139 test(s) passed, 4 skipped, 0 failed. mipsel/malta | 139 test(s) passed, 4 skipped, 0 failed. loongarch64/virt | 139 test(s) passed, 4 skipped, 0 failed.
Great, I like this, thank you! That was precisely the purpose of the "skipped" initially, not to be too strictly bound to a specific config. Now it's indeed even more flexible and that's better.
Series queued as well, thank you! Willy
Zhangjin,
for your convenience, I've queued your pending series and Thomas's patches in the following order here: 20230709-nolibc-ser2-tom-syscall-configv4
series2, thomas' chmod_net and ioperm patches, your new syscall series, and your tiny config version 4 series.
Thomas and Zhangjin, do not hesitate to let me know if I missed anything. The two series I left aside for now are still just under discussion (output reformating and reorganisation of the arch include files).
We're getting closer to having something done now!
Thanks! Willy
linux-kselftest-mirror@lists.linaro.org