From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Muhammad Usama Anjum" <usama.anjum@collabora.com>,
"Sasha Levin" <sashal@kernel.org>,
luto@kernel.org, vincenzo.frascino@arm.com,
linux-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.16 50/85] selftests: vDSO: vdso_test_getrandom: Always print TAP header
Date: Sun, 3 Aug 2025 20:22:59 -0400 [thread overview]
Message-ID: <20250804002335.3613254-50-sashal@kernel.org> (raw)
In-Reply-To: <20250804002335.3613254-1-sashal@kernel.org>
From: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
[ Upstream commit 1158220b24674edaf885433153deb4f0e5c7d331 ]
The TAP specification requires that the output begins with a header line.
If vgetrandom_init() fails and skips the test, that header line is missing.
Call vgetrandom_init() after ksft_print_header().
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Link: https://lore.kernel.org/all/20250611-selftests-vdso-fixes-v3-8-e62e37a6bcf5@linutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
**Backport Status: YES**
This commit should be backported to stable kernel trees. Here's my
extensive analysis:
## Analysis of the Commit
### 1. Bug Description
The commit fixes a test output formatting bug in the vDSO getrandom
selftest. Looking at the code changes in
`tools/testing/selftests/vDSO/vdso_test_getrandom.c`:
**Before the fix (lines 239-245 and 296-298 in the original file):**
```c
static void kselftest(void)
{
// ... variables ...
ksft_print_header();
ksft_set_plan(2);
// ... test code ...
}
int main(int argc, char *argv[])
{
vgetrandom_init(); // This was called BEFORE ksft_print_header()
if (argc == 1) {
kselftest();
return 0;
}
// ...
}
```
**After the fix:**
```c
static void kselftest(void)
{
// ... variables ...
ksft_print_header();
vgetrandom_init(); // Moved AFTER ksft_print_header()
ksft_set_plan(2);
// ... test code ...
}
int main(int argc, char *argv[])
{
if (argc == 1) {
kselftest();
return 0;
}
// ...
vgetrandom_init(); // Called here for non-test modes
// ...
}
```
### 2. Why This is a Bug
The TAP (Test Anything Protocol) specification requires that test output
begins with a version header line (`TAP version 13`). The
`ksft_print_header()` function prints this required header.
Looking at `vgetrandom_init()` (lines 113-131), it contains multiple
`ksft_exit_skip()` calls that can terminate the test early:
- Line 121: If `AT_SYSINFO_EHDR` is not present
- Line 125: If the vDSO symbol is missing
- Line 128: If the CPU doesn't have runtime support
When `vgetrandom_init()` was called before `ksft_print_header()`, these
skip conditions would exit the test without printing the TAP header,
violating the TAP specification and potentially breaking test harnesses
that parse the output.
### 3. Stable Backport Criteria Assessment
✓ **Fixes a bug that affects users**: Yes, this fixes incorrect test
output that can break automated test systems and CI/CD pipelines that
parse TAP output.
✓ **Relatively small and contained**: Yes, the fix is minimal - it just
reorders two function calls to ensure proper TAP header output.
✓ **No major side effects**: The change only affects test output
ordering, not functionality. The test logic remains identical.
✓ **No architectural changes**: This is a simple reordering of existing
calls with no structural changes.
✓ **Minimal risk**: The change is confined to the selftest code and
cannot affect kernel runtime behavior.
✓ **Important for testing infrastructure**: Correct TAP output is
crucial for test automation systems used in continuous integration and
validation of stable kernels.
### 4. Additional Considerations
- The commit message clearly describes the problem and solution
- The fix follows established kselftest patterns (header before any
potential exits)
- This is a test-only change with zero impact on production kernel code
- The bug could cause false test results in automated systems that
expect valid TAP output
This is an ideal candidate for stable backporting as it fixes a real bug
in test infrastructure with minimal risk and clear benefits for kernel
testing and validation.
tools/testing/selftests/vDSO/vdso_test_getrandom.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
index 95057f7567db..ff8d5675da2b 100644
--- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c
+++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
@@ -242,6 +242,7 @@ static void kselftest(void)
pid_t child;
ksft_print_header();
+ vgetrandom_init();
ksft_set_plan(2);
for (size_t i = 0; i < 1000; ++i) {
@@ -295,8 +296,6 @@ static void usage(const char *argv0)
int main(int argc, char *argv[])
{
- vgetrandom_init();
-
if (argc == 1) {
kselftest();
return 0;
@@ -306,6 +305,9 @@ int main(int argc, char *argv[])
usage(argv[0]);
return 1;
}
+
+ vgetrandom_init();
+
if (!strcmp(argv[1], "bench-single"))
bench_single();
else if (!strcmp(argv[1], "bench-multi"))
--
2.39.5
next prev parent reply other threads:[~2025-08-04 0:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250804002335.3613254-1-sashal@kernel.org>
2025-08-04 0:22 ` [PATCH AUTOSEL 6.16 09/85] regulator: core: repeat voltage setting request for stepped regulators Sasha Levin
2025-08-04 11:36 ` Mark Brown
2025-08-16 13:09 ` Sasha Levin
2025-08-04 0:22 ` [PATCH AUTOSEL 6.16 18/85] binder: Fix selftest page indexing Sasha Levin
2025-08-04 0:22 ` [PATCH AUTOSEL 6.16 49/85] irqchip/renesas-rzv2h: Enable SKIP_SET_WAKE and MASK_ON_SUSPEND Sasha Levin
2025-08-04 0:22 ` Sasha Levin [this message]
2025-08-04 0:23 ` [PATCH AUTOSEL 6.16 56/85] mei: bus: Check for still connected devices in mei_cl_bus_dev_release() Sasha Levin
2025-08-04 0:23 ` [PATCH AUTOSEL 6.16 67/85] irqchip/mips-gic: Allow forced affinity Sasha Levin
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=20250804002335.3613254-50-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=thomas.weissschuh@linutronix.de \
--cc=usama.anjum@collabora.com \
--cc=vincenzo.frascino@arm.com \
/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