Skip to contentSkip to conversation

cobalt/posix/clock: Allow NULL resolution on clock_getres64

PATCH In review Jan Kiszka 2 participants 3 messages May 27, 2025

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH v2 1/1 cobalt/posix/clock: Allow NULL resolution on clock_getres64

From: Jan Kiszka <[email protected]>

Permitted according to POSIX spec. Adjust the testsuite accordingly.

Fixes 633022801750 ("y2038: cobalt/posix/clock: Adding clock_getres64")

---

Changes in v2:
- also adjust the test case

 kernel/cobalt/posix/clock.c            | 2 +-
 testsuite/smokey/y2038/syscall-tests.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
kernel/cobalt/posix/clock.c +1 -1
index 845918a4a1..e6c187ca40 100644
@@ -103,7 +103,7 @@ COBALT_SYSCALL(clock_getres64, current,
 	if (ret)
 		return ret;
 
-	if (cobalt_put_timespec64(&ts, u_ts))
+	if (u_ts && cobalt_put_timespec64(&ts, u_ts))
 		return -EFAULT;
 
 	trace_cobalt_clock_getres(clock_id, &ts);
testsuite/smokey/y2038/syscall-tests.c +3 -3
index 7b56d281a6..4318712cc4 100644
@@ -363,13 +363,13 @@ static int test_sc_cobalt_clock_getres64(void)
 	struct xn_timespec64 ts64;
 	int ret;
 
-	/* Make sure we don't crash because of NULL pointers */
-	ret = XENOMAI_SYSCALL2(sc_nr, NULL, NULL);
+	/* Make sure we accept a NULL pointer */
+	ret = XENOMAI_SYSCALL2(sc_nr, CLOCK_MONOTONIC, NULL);
 	if (ret == -ENOSYS) {
 		smokey_note("clock_getres64: skipped. (no kernel support)");
 		return 0; // Not implemented, nothing to test, success
 	}
-	if (!smokey_assert(ret == -EFAULT))
+	if (!smokey_assert(ret == 0))
 		return ret ? ret : -EINVAL;
 
 	/* Providing an invalid address has to deliver EFAULT */
Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Permitted according to POSIX spec. Adjust the testsuite accordingly.

Fixes 633022801750 ("y2038: cobalt/posix/clock: Adding clock_getres64")
Quoted 32 lines

---

Changes in v2:
- also adjust the test case

 kernel/cobalt/posix/clock.c            | 2 +-
 testsuite/smokey/y2038/syscall-tests.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
kernel/cobalt/posix/clock.c +1 -1
index 845918a4a1..e6c187ca40 100644
@@ -103,7 +103,7 @@ COBALT_SYSCALL(clock_getres64, current,
 	if (ret)
 		return ret;
 
-	if (cobalt_put_timespec64(&ts, u_ts))
+	if (u_ts && cobalt_put_timespec64(&ts, u_ts))
 		return -EFAULT;
 
 	trace_cobalt_clock_getres(clock_id, &ts);
testsuite/smokey/y2038/syscall-tests.c +0 -1
index 7b56d281a6..4318712cc4 100644
@@ -363,13 +363,13 @@ static int test_sc_cobalt_clock_getres64(void)
 	struct xn_timespec64 ts64;
 	int ret;
 
-	/* Make sure we don't crash because of NULL pointers */

testsuite/smokey/y2038/syscall-tests.c static int test_sc_cobalt_clock_getres64(void) · line 373

Quoted 10 lines
testsuite/smokey/y2038/syscall-tests.c +3 -2
-	ret = XENOMAI_SYSCALL2(sc_nr, NULL, NULL);
+	/* Make sure we accept a NULL pointer */
+	ret = XENOMAI_SYSCALL2(sc_nr, CLOCK_MONOTONIC, NULL);
 	if (ret == -ENOSYS) {
 		smokey_note("clock_getres64: skipped. (no kernel support)");
 		return 0; // Not implemented, nothing to test, success
 	}
-	if (!smokey_assert(ret == -EFAULT))
+	if (!smokey_assert(ret == 0))
 		return ret ? ret : -EINVAL;

Seems a pipeline run revealed the missing test adjustments ;-)

Quoted 3 lines
testsuite/smokey/y2038/syscall-tests.c +0 -0
 	/* Providing an invalid address has to deliver EFAULT */
Signature · 1 line
2.43.0
author
#2 lore raw
Quoted 40 lines · Florian Bezdeka
Quoted 5 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Permitted according to POSIX spec. Adjust the testsuite accordingly.

Fixes 633022801750 ("y2038: cobalt/posix/clock: Adding clock_getres64")
Quoted 31 lines

---

Changes in v2:
- also adjust the test case

 kernel/cobalt/posix/clock.c            | 2 +-
 testsuite/smokey/y2038/syscall-tests.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
kernel/cobalt/posix/clock.c +1 -1
index 845918a4a1..e6c187ca40 100644
@@ -103,7 +103,7 @@ COBALT_SYSCALL(clock_getres64, current,
 	if (ret)
 		return ret;
 
-	if (cobalt_put_timespec64(&ts, u_ts))
+	if (u_ts && cobalt_put_timespec64(&ts, u_ts))
 		return -EFAULT;
 
 	trace_cobalt_clock_getres(clock_id, &ts);
testsuite/smokey/y2038/syscall-tests.c +0 -0
index 7b56d281a6..4318712cc4 100644
@@ -363,13 +363,13 @@ static int test_sc_cobalt_clock_getres64(void)
 	struct xn_timespec64 ts64;
 	int ret;
 
Quoted 14 lines

testsuite/smokey/y2038/syscall-tests.c static int test_sc_cobalt_clock_getres64(void) · line 373

Quoted 11 lines
testsuite/smokey/y2038/syscall-tests.c +3 -3
-	/* Make sure we don't crash because of NULL pointers */
-	ret = XENOMAI_SYSCALL2(sc_nr, NULL, NULL);
+	/* Make sure we accept a NULL pointer */
+	ret = XENOMAI_SYSCALL2(sc_nr, CLOCK_MONOTONIC, NULL);
 	if (ret == -ENOSYS) {
 		smokey_note("clock_getres64: skipped. (no kernel support)");
 		return 0; // Not implemented, nothing to test, success
 	}
-	if (!smokey_assert(ret == -EFAULT))
+	if (!smokey_assert(ret == 0))
 		return ret ? ret : -EINVAL;

Seems a pipeline run revealed the missing test adjustments ;-)

Yes...

That should also cover you comment on v1 which I only saw now.

Jan

Quoted 5 lines
Quoted 4 lines
testsuite/smokey/y2038/syscall-tests.c +0 -0
 	/* Providing an invalid address has to deliver EFAULT */
Signature · 1 line
2.43.0
Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center