* [PATCH] selftests: timers: skip raw_skew when adjtimex fails
@ 2026-10-07 11:16 Daniel Syauqi
0 siblings, 0 replies; only message in thread
From: Daniel Syauqi @ 2026-10-07 11:16 UTC (permalink / raw)
To: John Stultz, Thomas Gleixner, Shuah Khan
Cc: Stephen Boyd, Miroslav Lichvar, Anna-Maria Behnsen,
Frederic Weisbecker, linux-kernel, linux-kselftest
raw_skew reads frequency and offset data from adjtimex() without checking
whether either query succeeded. If a sandbox blocks the syscall, the
test can use uninitialized data and wait two minutes before producing a
misleading result.
Skip on either failure and report the syscall error. Preserve errno
across the newline printed after the second query.
Fixes: 51f91cbdf545 ("selftests/timers: Add clock skew estimation test from timetest suite")
Assisted-by: LLM Codex
Signed-off-by: Daniel Syauqi <syauqicode@gmail.com>
---
Tool assistance: OpenAI Codex helped identify the unchecked adjtimex()
returns, draft the fix and changelog, and create failure-path tests.
Prompt summary: Investigate the unchecked adjtimex() calls in raw_skew
and prepare and test a narrow selftest fix. The affected content is
raw_skew.c error handling and this changelog.
Tests: Built raw_skew with make. Forced EPERM at each adjtimex() call
separately with LD_PRELOAD; both runs skipped with exit status 4. A
normal raw_skew run passed, and targeted timer selftests had no failures.
The full kernel test suite was not run.
tools/testing/selftests/timers/raw_skew.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/timers/raw_skew.c b/tools/testing/selftests/timers/raw_skew.c
index 0c87a8fb0..2ad5e2e35 100644
--- a/tools/testing/selftests/timers/raw_skew.c
+++ b/tools/testing/selftests/timers/raw_skew.c
@@ -19,7 +19,9 @@
* GNU General Public License for more details.
*/
+#include <errno.h>
#include <stdio.h>
+#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/time.h>
@@ -101,7 +103,8 @@ int main(int argc, char **argv)
}
tx1.modes = 0;
- adjtimex(&tx1);
+ if (adjtimex(&tx1) < 0)
+ ksft_exit_skip("adjtimex failed: %s\n", strerror(errno));
get_monotonic_and_raw(&mon, &raw);
start = mon;
delta1 = diff_timespec(mon, raw);
@@ -116,7 +119,12 @@ int main(int argc, char **argv)
get_monotonic_and_raw(&mon, &raw);
end = mon;
tx2.modes = 0;
- adjtimex(&tx2);
+ if (adjtimex(&tx2) < 0) {
+ int saved_errno = errno;
+
+ printf("\n");
+ ksft_exit_skip("adjtimex failed: %s\n", strerror(saved_errno));
+ }
delta2 = diff_timespec(mon, raw);
interval = diff_timespec(start, end);
base-commit: 602042bf29f6efde39cfb5fdd9289bf4854bc0c5
--
2.47.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-07 11:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-07 11:16 [PATCH] selftests: timers: skip raw_skew when adjtimex fails Daniel Syauqi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®