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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250804003119.3620476-41-sashal@kernel.org>
Date: Sun,  3 Aug 2025 20:30:51 -0400
From: Sasha Levin <sashal@...nel.org>
To: patches@...ts.linux.dev,
	stable@...r.kernel.org
Cc: Thomas Weißschuh <thomas.weissschuh@...utronix.de>,
	Thomas Gleixner <tglx@...utronix.de>,
	Muhammad Usama Anjum <usama.anjum@...labora.com>,
	Sasha Levin <sashal@...nel.org>,
	luto@...nel.org,
	vincenzo.frascino@....com,
	linux-kernel@...r.kernel.org
Subject: [PATCH AUTOSEL 6.12 41/69] selftests: vDSO: vdso_test_getrandom: Always print TAP header

From: Thomas Weißschuh <thomas.weissschuh@...utronix.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@...utronix.de>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@...labora.com>
Link: https://lore.kernel.org/all/20250611-selftests-vdso-fixes-v3-8-e62e37a6bcf5@linutronix.de
Signed-off-by: Sasha Levin <sashal@...nel.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ