[no subject]

From: Regen Yang

Date: Sat Oct 31 2026 - 14:21:16 EST


run_kselftest.sh sources runner.sh under /bin/sh, but run_in_netns()
uses Bash's &> redirection for running a test and deleting its namespace.
With dash, this backgrounds the command and performs a separate
redirection-only command. Consequently, rc captures the successful
redirection instead of the test status, and namespace cleanup can race
with test execution.

A failing test run with run_kselftest.sh -n can therefore be counted as a
pass and return success. The totals can also appear before the test
result, and skipped and expected-failure tests are counted as passes.

Use portable stdout and stderr redirections so the runner waits for the
test and namespace cleanup, preserves the test status, and reads the log
after the test has finished.

Fixes: 9d0b4ad82d61 ("kselftest/runner.sh: add netns support")
Signed-off-by: Regen Yang <regentropfen.yang@xxxxxxxxx>
---
tools/testing/selftests/kselftest/runner.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kselftest/runner.sh
b/tools/testing/selftests/kselftest/runner.sh
index 45fb8ec38493..38b364da2573 100644
--- a/tools/testing/selftests/kselftest/runner.sh
+++ b/tools/testing/selftests/kselftest/runner.sh
@@ -186,10 +186,10 @@ run_in_netns()
fi
ip -n $netns link set lo up

- in_netns $netns &> $tmplog
+ in_netns $netns > $tmplog 2>&1
rc=$?

- ip netns del $netns &> /dev/null
+ ip netns del $netns > /dev/null 2>&1
# Cat the log at once to avoid parallel netns logs.
cat $tmplog
rm -f $tmplog
--