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>] [day] [month] [year] [list]
Message-ID: <2fa14a04f5287c956a1112cef8cdfb2c86931d2d.1768467496.git.tanggeliang@kylinos.cn>
Date: Thu, 15 Jan 2026 17:02:40 +0800
From: Geliang Tang <geliang@...nel.org>
To: John Fastabend <john.fastabend@...il.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Sabrina Dubroca <sd@...asysnail.net>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Paolo Abeni <pabeni@...hat.com>,
	Simon Horman <horms@...nel.org>,
	Shuah Khan <shuah@...nel.org>
Cc: Gang Yan <yangang@...inos.cn>,
	netdev@...r.kernel.org,
	linux-kselftest@...r.kernel.org,
	mptcp@...ts.linux.dev,
	Geliang Tang <geliang@...nel.org>
Subject: [PATCH net-next v2] selftests: tls: use mkstemp instead of open(O_TMPFILE)

From: Gang Yan <yangang@...inos.cn>

When running TLS tests in a virtual machine/container environment, they
fail in test_mutliproc():

 # tls.c:1479:mutliproc_even: Expected fd (-1) >= 0 (0)
 # mutliproc_even: Test terminated by assertion
 #          FAIL  tls.12_aes_gcm.mutliproc_even
 not ok 59 tls.12_aes_gcm.mutliproc_even
 #  RUN           tls.12_aes_gcm.mutliproc_readers ...
 # tls.c:1479:mutliproc_readers: Expected fd (-1) >= 0 (0)
 # mutliproc_readers: Test terminated by assertion
 #          FAIL  tls.12_aes_gcm.mutliproc_readers
 not ok 60 tls.12_aes_gcm.mutliproc_readers
 #  RUN           tls.12_aes_gcm.mutliproc_writers ...
 # tls.c:1479:mutliproc_writers: Expected fd (-1) >= 0 (0)
 # mutliproc_writers: Test terminated by assertion
 #          FAIL  tls.12_aes_gcm.mutliproc_writers
 not ok 61 tls.12_aes_gcm.mutliproc_writers

This is because the /tmp directory uses the virtiofs filesystem, which does
not support the O_TMPFILE feature.

This patch uses mkstemp() to create temporary files, just like the approach
used in chunked_sendfile(), thereby eliminating the dependency on the
O_TMPFILE feature.

For better code reuse, factor out this code from chunked_sendfile() into a
separate helper create_temp_file(). Use this new heler in test_mutliproc()
and closes the file descriptor (fd) after the test ends.

Co-developed-by: Geliang Tang <geliang@...nel.org>
Signed-off-by: Geliang Tang <geliang@...nel.org>
Signed-off-by: Gang Yan <yangang@...inos.cn>
---
v2:
 - factor out a new helper, use it in both chunked_sendfile() and
   test_mutliproc().
---
 tools/testing/selftests/net/tls.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
index 9e2ccea13d70..2eaacb7f2e56 100644
--- a/tools/testing/selftests/net/tls.c
+++ b/tools/testing/selftests/net/tls.c
@@ -467,6 +467,15 @@ TEST_F(tls, send_then_sendfile)
 	close(filefd);
 }
 
+static int create_temp_file(void)
+{
+	char filename[] = "/tmp/mytemp.XXXXXX";
+	int fd = mkstemp(filename);
+
+	unlink(filename);
+	return fd;
+}
+
 static void chunked_sendfile(struct __test_metadata *_metadata,
 			     struct _test_data_tls *self,
 			     uint16_t chunk_size,
@@ -476,11 +485,9 @@ static void chunked_sendfile(struct __test_metadata *_metadata,
 	uint16_t test_payload_size;
 	int size = 0;
 	int ret;
-	char filename[] = "/tmp/mytemp.XXXXXX";
-	int fd = mkstemp(filename);
+	int fd = create_temp_file();
 	off_t offset = 0;
 
-	unlink(filename);
 	ASSERT_GE(fd, 0);
 	EXPECT_GE(chunk_size, 1);
 	test_payload_size = chunk_size + extra_payload_size;
@@ -1469,7 +1476,7 @@ test_mutliproc(struct __test_metadata *_metadata, struct _test_data_tls *self,
 	write_bias = n_readers / n_writers ?: 1;
 
 	/* prep a file to send */
-	fd = open("/tmp/", O_TMPFILE | O_RDWR, 0600);
+	fd = create_temp_file();
 	ASSERT_GE(fd, 0);
 
 	memset(buf, 0xac, file_sz);
@@ -1527,6 +1534,7 @@ test_mutliproc(struct __test_metadata *_metadata, struct _test_data_tls *self,
 			left -= res;
 		}
 	}
+	close(fd);
 }
 
 TEST_F(tls, mutliproc_even)
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ