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]
Message-Id: <55a01001987f2795a982755ed2ca8e27efe49249.1687344643.git.falcon@tinylab.org>
Date:   Wed, 21 Jun 2023 21:18:53 +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 16/17] selftests/nolibc: vfprintf: skip if neither tmpfs nor hugetlbfs

As fs/Kconfig shows, MEMFD_CREATE depends on TMPFS or HUGETLBFS:

    config MEMFD_CREATE
    	def_bool TMPFS || HUGETLBFS

Let's skip vfprintf test if they are not there.

The /tmp and /hugetlb directories have been created to mount tmpfs and
hugetlbfs respectively, if they are not enabled in kernel configuration,
neither /tmp nor /hugetlb will be created.

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

diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 8b1ce9911c5c..85fa64746cde 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -769,11 +769,22 @@ int run_stdlib(int min, int max)
 
 static int expect_vfprintf(int llen, size_t c, const char *expected, const char *fmt, ...)
 {
+	struct stat stat_buf;
 	int ret, fd, w, r;
+	int tmpfs = 0, hugetlbfs = 0;
 	char buf[100];
 	FILE *memfile;
 	va_list args;
 
+	/* memfd_create depends on tmpfs or hugetlbfs */
+	tmpfs = stat("/tmp/.", &stat_buf) == 0;
+	hugetlbfs = stat("/hugetlb/.", &stat_buf) == 0;
+
+	if (!tmpfs && !hugetlbfs) {
+		pad_spc(llen, 64, "[SKIPPED]\n");
+		return 0;
+	}
+
 	/* silence warning for kernel >= v6.2:
 	 *
 	 *   "memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL, pid=<pid>"
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ