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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251113-vdso-test-types-v2-10-0427eff70d08@linutronix.de>
Date: Thu, 13 Nov 2025 16:30:26 +0100
From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
To: Andy Lutomirski <luto@...nel.org>, Thomas Gleixner <tglx@...utronix.de>, 
 Vincenzo Frascino <vincenzo.frascino@....com>, 
 Shuah Khan <shuah@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>, linux-kernel@...r.kernel.org, 
 linux-kselftest@...r.kernel.org, 
 Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Subject: [PATCH v2 10/14] selftests: vDSO: vdso_test_correctness: Make
 ts_leq() and tv_leq() more generic

Upcoming changes will shuffle around the timespec and timeval types.
To keep ts_leq() and tv_leq() working with all of those types, transform
them into macros.

Also drop ts64_leq() as it can now be replaced by the regular ts_leq().

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
---
 .../testing/selftests/vDSO/vdso_test_correctness.c | 47 ++++++++++------------
 1 file changed, 22 insertions(+), 25 deletions(-)

diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c b/tools/testing/selftests/vDSO/vdso_test_correctness.c
index 66cd1d4c19872e78c0e608f5e0fb5215cf902b50..5a127fc93e7368cbe8d9fb4a4482a6a735ffd46c 100644
--- a/tools/testing/selftests/vDSO/vdso_test_correctness.c
+++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c
@@ -213,30 +213,27 @@ static void test_getcpu(void)
 	}
 }
 
-static bool ts_leq(const struct timespec *a, const struct timespec *b)
-{
-	if (a->tv_sec != b->tv_sec)
-		return a->tv_sec < b->tv_sec;
-	else
-		return a->tv_nsec <= b->tv_nsec;
-}
-
-static bool ts64_leq(const struct __kernel_timespec *a,
-		     const struct __kernel_timespec *b)
-{
-	if (a->tv_sec != b->tv_sec)
-		return a->tv_sec < b->tv_sec;
-	else
-		return a->tv_nsec <= b->tv_nsec;
-}
-
-static bool tv_leq(const struct timeval *a, const struct timeval *b)
-{
-	if (a->tv_sec != b->tv_sec)
-		return a->tv_sec < b->tv_sec;
-	else
-		return a->tv_usec <= b->tv_usec;
-}
+#define ts_leq(_a, _b)	({				\
+	bool _ret;					\
+							\
+	if ((_a)->tv_sec != (_b)->tv_sec)		\
+		_ret = (_a)->tv_sec < (_b)->tv_sec;	\
+	else						\
+		_ret = (_a)->tv_nsec <= (_b)->tv_nsec;	\
+							\
+	_ret;						\
+})
+
+#define tv_leq(_a, _b)	({				\
+	bool _ret;					\
+							\
+	if ((_a)->tv_sec != (_b)->tv_sec)		\
+		_ret = (_a)->tv_sec < (_b)->tv_sec;	\
+	else						\
+		_ret = (_a)->tv_usec <= (_b)->tv_usec;	\
+							\
+	_ret;						\
+})
 
 static char const * const clocknames[] = {
 	[0] = "CLOCK_REALTIME",
@@ -352,7 +349,7 @@ static void test_one_clock_gettime64(int clock, const char *name)
 	       (unsigned long long)vdso.tv_sec, vdso.tv_nsec,
 	       (unsigned long long)end.tv_sec, end.tv_nsec);
 
-	if (!ts64_leq(&start, &vdso) || !ts64_leq(&vdso, &end)) {
+	if (!ts_leq(&start, &vdso) || !ts_leq(&vdso, &end)) {
 		printf("[FAIL]\tTimes are out of sequence\n");
 		nerrs++;
 		return;

-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ