lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 21 Jun 2023 21:09:24 +0800
From:   Zhangjin Wu <falcon@...ylab.org>
To:     w@....eu
Cc:     thomas@...ch.de, arnd@...db.de, falcon@...ylab.org,
        linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: [PATCH v1 12/17] selftests/nolibc: rename chmod_net to chmod_good

When CONFIG_NET is not enabled, there would be no /proc/self/net, let's
use /tmp/blah in such case and rename chmod_net to chmod_good.

This allows to test chmod_good with tmpfs even when procfs is not there.

Signed-off-by: Zhangjin Wu <falcon@...ylab.org>
---
 tools/testing/selftests/nolibc/nolibc-test.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 8b587961e46a..eca0070151b6 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -550,10 +550,22 @@ int run_syscall(int min, int max)
 	int ret = 0;
 	void *p1, *p2;
 	int has_gettid = 1;
+	int has_tmpdir = 0;
+	char *tmpdir = NULL;
 
 	/* <has_proc> indicates whether or not /proc is mounted */
 	has_proc = stat("/proc", &stat_buf) == 0;
 
+	/* <has_tmpdir> indicates whether or not /tmp/blah is there */
+	if (stat("/proc/self/net", &stat_buf) == 0) {
+		tmpdir = "/proc/self/net";
+		has_tmpdir = 1;
+	} else if (stat("/tmp/.", &stat_buf) == 0) {
+		tmpdir = "/tmp/blah";
+		if (mkdir(tmpdir, 0755) == 0)
+			has_tmpdir = 1;
+	}
+
 	/* this will be used to skip certain tests that can't be run unprivileged */
 	is_root = geteuid() == 0;
 
@@ -582,7 +594,7 @@ int run_syscall(int min, int max)
 		CASE_TEST(chdir_root);        EXPECT_SYSZR(1, chdir("/")); 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_net);         EXPECT_SYSZR(has_proc, chmod("/proc/self/net", 0555)); break;
+		CASE_TEST(chmod_good);        EXPECT_SYSZR(has_tmpdir, chmod(tmpdir, 0555)); break;
 		CASE_TEST(chmod_self);        EXPECT_SYSER(has_proc, chmod("/proc/self", 0555), -1, EPERM); break;
 		CASE_TEST(chown_self);        EXPECT_SYSER(has_proc, chown("/proc/self", 0, 0), -1, EPERM); break;
 		CASE_TEST(chroot_root);       EXPECT_SYSZR(is_root, chroot("/")); break;
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ