Skip to contentSkip to conversation

perf test: Skip failing 'perf test aslr' test case

PATCH Superseded Thomas Richter 4 participants 4 messages Jun 19 – Jun 24

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf test: Skip failing 'perf test aslr' test case

The test case 'perf test aslr' fails on s390. The root cause of the failure is subtest test_callchain_aslr. This test invokes command

 # ./perf record -g -e task-clock:u -o /tmp/perf-test-aslr \
	-- perf test -w noploop 3

to generate a call stack using event task-clock:u. On s390 this defaults to '--call-graph dwarf' whereas on x86_64 this defaults to framepointer (fp) format. The command

 # ./perf inject --aslr -i /tmp/perf-test-aslr

now scans all SAMPLE entries recorded in the perf.data file to convert possible addresses. This is done in aslr_tool__process_sample() looking at sample_type bits PERF_SAMPLE_IP, PERF_SAMPLE_TID, PERF_SAMPLE_TIME, PERF_SAMPLE_PERIOD, PERF_SAMPLE_CALLCHAIN, PERF_SAMPLE_REGS_USER and PERF_SAMPLE_STACK_USER.
On s390 the samples do not contain FP entries
of type PERF_SAMPLE_CALLCHAIN (the bit is set in sample_type, but the number of FP entries is 0).
The processing enters the PERF_SAMPLE_STACK_USER portion where the data is copied to the newly constructed sample and then aborted with this warning:

/* TODO: can this be less conservative? */ pr_debug("Dropping stack user sample as possible ASLR leak\n");

With command line option '--call-graph dwarf' the new output file does not contain any samples at all. This leads to a missing $new_addr value in the shell script and a failure.

Fix this and skip this subtest. Emit a hint that this subtest is currently unsupported on all platform when option --call-graph dwarf is selected.
Since one subtest is skipped, the complete test is reported as skipped.

Fixes 60bc9fbc0589 ("perf test: Add inject ASLR test")
Cc Ian Rogers <[email protected]>
---
 tools/perf/tests/shell/inject_aslr.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
tools/perf/tests/shell/inject_aslr.sh +9 -2
index c00461828ea7..7fdb43679dc8 100755
@@ -135,8 +135,15 @@ test_callchain_aslr() {
     echo "Callchain ASLR test [Failed - no noploop samples in original file]"
     err=1
   elif [ -z "$new_addr" ]; then
-    echo "Callchain ASLR test [Failed - could not find remapped address]"
-    err=1
+    if perf evlist -v -i "${data}" | grep -q 'sample_type:.*STACK_USER'; then
+      echo "Dropping stack user sample as possible ASLR leak"
+      echo "Call-graph dwarf not supported with 'perf inject --aslr'"
+      echo "Callchain ASLR test [Skip]"
+      err=2
+    else
+      echo "Callchain ASLR test [Failed - could not find remapped address]"
+      err=1
+    fi
   elif [ "$orig_addr" = "$new_addr" ]; then
     echo "Callchain ASLR test [Failed - addresses are not remapped]"
     err=1
Signature · 1 line
2.54.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] Unconditionally setting `err=2` when skipping `test_callchain_aslr` masks prior test failures.…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Unconditionally setting err=2 when skipping test_callchain_aslr masks prior test failures.
- [Medium] Skipping the test incorrectly triggers the test failure cleanup path, leaking the temporary directory in /tmp/. --

commit d772895777a1677561d1802ac157c32ce73e1379
Author: Thomas Richter <[email protected]>

perf test: Skip failing 'perf test aslr' test case

The test case 'perf test aslr' fails on s390. This commit fixes the failure by skipping the subtest test_callchain_aslr and emitting a hint when the --call-graph dwarf option is selected.

Fixes 60bc9fbc0589 ("perf test: Add inject ASLR test")
Quoted 5 lines
tools/perf/tests/shell/inject_aslr.sh +0 -0
index c00461828ea79..7fdb43679dc84 100755

tools/perf/tests/shell/inject_aslr.sh test_callchain_aslr() { · line 142

Quoted 10 lines
tools/perf/tests/shell/inject_aslr.sh +5 -2
@@ -135,8 +135,15 @@ test_callchain_aslr() {
     echo "Callchain ASLR test [Failed - no noploop samples in original file]"
     err=1
   elif [ -z "$new_addr" ]; then
-    echo "Callchain ASLR test [Failed - could not find remapped address]"
-    err=1
+    if perf evlist -v -i "${data}" | grep -q 'sample_type:.*STACK_USER'; then
+      echo "Dropping stack user sample as possible ASLR leak"
+      echo "Call-graph dwarf not supported with 'perf inject --aslr'"
+      echo "Callchain ASLR test [Skip]"
+      err=2

[Severity: Medium]
Does unconditionally setting err=2 here mask prior test failures?

If an earlier subtest fails, the global err variable is set to 1. When test_callchain_aslr() decides to skip and assigns err=2, it overwrites this previous failure state.

Since the perf test framework treats an exit code of 2 as a SKIP, the test suite will report the entire script as skipped, completely hiding the actual failure from the prior subtest.

[Severity: Medium]
Will skipping this test inadvertently trigger the test failure cleanup path and leak the temporary directory?

The cleanup() function in tools/perf/tests/shell/inject_aslr.sh explicitly aborts deletion if the exit code or err is non-zero:

cleanup() {
if [ "${exit_code}" -ne 0 ] || [ "${err}" -ne 0 ]; then

    echo "Test failed! Preserving temp directory: ${temp_dir}"
    return

fi
...
}

Because cleanup() was not updated to handle the new skip state, it mistakenly treats err=2 as a test failure. This unconditionally leaves behind the /tmp/perf-test-aslr.XXXXXX directory every time the test skips.

Quoted 7 lines
tools/perf/tests/shell/inject_aslr.sh +4 -0
+    else
+      echo "Callchain ASLR test [Failed - could not find remapped address]"
+      err=1
+    fi
   elif [ "$orig_addr" = "$new_addr" ]; then
     echo "Callchain ASLR test [Failed - addresses are not remapped]"
     err=1
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
reviewer Reviewed-by
#2 lore raw
Quoted 48 lines · On Fri, Jun 19, 2026 at 2:42 AM <[email protected]> wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Unconditionally setting err=2 when skipping test_callchain_aslr masks prior test failures.
- [Medium] Skipping the test incorrectly triggers the test failure cleanup path, leaking the temporary directory in /tmp/. --

commit d772895777a1677561d1802ac157c32ce73e1379
Author: Thomas Richter <[email protected]>

perf test: Skip failing 'perf test aslr' test case

The test case 'perf test aslr' fails on s390. This commit fixes the failure by skipping the subtest test_callchain_aslr and emitting a hint when the --call-graph dwarf option is selected.

Fixes 60bc9fbc0589 ("perf test: Add inject ASLR test")
Quoted 5 lines
tools/perf/tests/shell/inject_aslr.sh +0 -0
index c00461828ea79..7fdb43679dc84 100755

tools/perf/tests/shell/inject_aslr.sh test_callchain_aslr() { · line 142

Quoted 10 lines
tools/perf/tests/shell/inject_aslr.sh +5 -2
@@ -135,8 +135,15 @@ test_callchain_aslr() {
     echo "Callchain ASLR test [Failed - no noploop samples in original file]"
     err=1
   elif [ -z "$new_addr" ]; then
-    echo "Callchain ASLR test [Failed - could not find remapped address]"
-    err=1
+    if perf evlist -v -i "${data}" | grep -q 'sample_type:.*STACK_USER'; then
+      echo "Dropping stack user sample as possible ASLR leak"
+      echo "Call-graph dwarf not supported with 'perf inject --aslr'"
+      echo "Callchain ASLR test [Skip]"
+      err=2

[Severity: Medium]
Does unconditionally setting err=2 here mask prior test failures?

If an earlier subtest fails, the global err variable is set to 1. When test_callchain_aslr() decides to skip and assigns err=2, it overwrites this previous failure state.

Since the perf test framework treats an exit code of 2 as a SKIP, the test suite will report the entire script as skipped, completely hiding the actual failure from the prior subtest.

[Severity: Medium]
Will skipping this test inadvertently trigger the test failure cleanup path and leak the temporary directory?

Quoted 5 lines

The cleanup() function in tools/perf/tests/shell/inject_aslr.sh explicitly aborts deletion if the exit code or err is non-zero:

cleanup() {
if [ "${exit_code}" -ne 0 ] || [ "${err}" -ne 0 ]; then

Thanks for the fix Thomas! I completely agree with what you've done, but it exposed this latent issue that we should make the exit_code/err comparison -eq 1 rather than -ne 0. Perhaps Arnaldo can fix this, or we can address it as a follow-up.

Thanks,
Ian

Quoted 21 lines
    echo "Test failed! Preserving temp directory: ${temp_dir}"
    return

fi
...
}

Because cleanup() was not updated to handle the new skip state, it mistakenly treats err=2 as a test failure. This unconditionally leaves behind the /tmp/perf-test-aslr.XXXXXX directory every time the test skips.

tools/perf/tests/shell/inject_aslr.sh test_callchain_aslr() { · line 149

Quoted 7 lines
tools/perf/tests/shell/inject_aslr.sh +4 -0
+    else
+      echo "Callchain ASLR test [Failed - could not find remapped address]"
+      err=1
+    fi
   elif [ "$orig_addr" = "$new_addr" ]; then
     echo "Callchain ASLR test [Failed - addresses are not remapped]"
     err=1

--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1

maintainer
#3 lore raw

Hello,

Quoted 10 lines · Ian Rogers
Quoted 9 lines · On Fri, Jun 19, 2026 at 2:42 AM <[email protected]> wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Unconditionally setting err=2 when skipping test_callchain_aslr masks prior test failures.
- [Medium] Skipping the test incorrectly triggers the test failure cleanup path, leaking the temporary directory in /tmp/. --

commit d772895777a1677561d1802ac157c32ce73e1379
Author: Thomas Richter <[email protected]>

Quoted 7 lines
Quoted 7 lines

perf test: Skip failing 'perf test aslr' test case

The test case 'perf test aslr' fails on s390. This commit fixes the failure by skipping the subtest test_callchain_aslr and emitting a hint when the --call-graph dwarf option is selected.

Fixes 60bc9fbc0589 ("perf test: Add inject ASLR test")

Shouldn't it be 190c45463844?

Quoted 20 lines
Quoted 20 lines
Quoted 6 lines
tools/perf/tests/shell/inject_aslr.sh +0 -0
index c00461828ea79..7fdb43679dc84 100755

tools/perf/tests/shell/inject_aslr.sh test_callchain_aslr() { · line 142

Quoted 10 lines
tools/perf/tests/shell/inject_aslr.sh +5 -2
@@ -135,8 +135,15 @@ test_callchain_aslr() {
     echo "Callchain ASLR test [Failed - no noploop samples in original file]"
     err=1
   elif [ -z "$new_addr" ]; then
-    echo "Callchain ASLR test [Failed - could not find remapped address]"
-    err=1
+    if perf evlist -v -i "${data}" | grep -q 'sample_type:.*STACK_USER'; then
+      echo "Dropping stack user sample as possible ASLR leak"
+      echo "Call-graph dwarf not supported with 'perf inject --aslr'"
+      echo "Callchain ASLR test [Skip]"
+      err=2

[Severity: Medium]
Does unconditionally setting err=2 here mask prior test failures?

Quoted 7 lines
Quoted 7 lines

If an earlier subtest fails, the global err variable is set to 1. When test_callchain_aslr() decides to skip and assigns err=2, it overwrites this previous failure state.

Since the perf test framework treats an exit code of 2 as a SKIP, the test suite will report the entire script as skipped, completely hiding the actual failure from the prior subtest.

Right, it should not overwrite if it's already 1.

Thanks,
Namhyng

Quoted 43 lines
Quoted 10 lines

[Severity: Medium]
Will skipping this test inadvertently trigger the test failure cleanup path and leak the temporary directory?

The cleanup() function in tools/perf/tests/shell/inject_aslr.sh explicitly aborts deletion if the exit code or err is non-zero:

cleanup() {
if [ "${exit_code}" -ne 0 ] || [ "${err}" -ne 0 ]; then

Thanks for the fix Thomas! I completely agree with what you've done, but it exposed this latent issue that we should make the exit_code/err comparison -eq 1 rather than -ne 0. Perhaps Arnaldo can fix this, or we can address it as a follow-up.

Thanks,
Ian

Quoted 21 lines
    echo "Test failed! Preserving temp directory: ${temp_dir}"
    return

fi
...
}

Because cleanup() was not updated to handle the new skip state, it mistakenly treats err=2 as a test failure. This unconditionally leaves behind the /tmp/perf-test-aslr.XXXXXX directory every time the test skips.

tools/perf/tests/shell/inject_aslr.sh test_callchain_aslr() { · line 149

Quoted 7 lines
tools/perf/tests/shell/inject_aslr.sh +4 -0
+    else
+      echo "Callchain ASLR test [Failed - could not find remapped address]"
+      err=1
+    fi
   elif [ "$orig_addr" = "$new_addr" ]; then
     echo "Callchain ASLR test [Failed - addresses are not remapped]"
     err=1

--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1