From: Daniel Syauqi <syauqicode@gmail.com>
To: John Stultz <jstultz@google.com>,
Thomas Gleixner <tglx@kernel.org>, Shuah Khan <shuah@kernel.org>
Cc: Stephen Boyd <sboyd@kernel.org>,
Miroslav Lichvar <mlichvar@redhat.com>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH] selftests: timers: skip raw_skew when adjtimex fails
Date: Wed, 7 Oct 2026 19:16:11 +0800 [thread overview]
Message-ID: <20261007111611.2086-1-syauqicode@gmail.com> (raw)
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
reply other threads:[~2026-10-07 11:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261007111611.2086-1-syauqicode@gmail.com \
--to=syauqicode@gmail.com \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mlichvar@redhat.com \
--cc=sboyd@kernel.org \
--cc=shuah@kernel.org \
--cc=tglx@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®