Skip to content

Commit d46865c

Browse files
authored
run-vmtest: make kernel_splat detection optional (#235)
* run-vmtest: make splat detection opt-in Existing action users do not necessarily carry kernel splat allowlist and denylist files. Treating a missing denylist as a detector failure therefore breaks those users when the v4 tag advances. Skip the detector when neither configured list path exists, while continuing to fail partial or invalid configurations once either file exists. With file presence as the feature gate, remove the test_progs-only check so configured test_maps and test_verifier runs are scanned too. Add regression coverage for configured paths with no list files. Assisted-by: Codex:GPT-5 Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> * run-vmtest: surface kernel splat details in job log The detector runs inside the outer vmtest log group, so its matched context remains collapsed even though it emits a GitHub error. Write a short diagnostic excerpt next to exitstatus and print it from the host after the vmtest group closes. Use its first line for the error annotation so the failure is visible immediately, while retaining dmesg.txt as the full-log artifact. Build the excerpt from the already allowlist-filtered hits. The previous second grep used the raw denylist again, reintroducing allowed matches and potentially printing thousands of unrelated lines. Add coverage for saved excerpts and a log containing both allowed and unallowed splats. Assisted-by: Codex:GPT-5 Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> * run-vmtest: reduce shell trace noise Global xtrace in the run-vmtest entry points logs every variable assignment and helper invocation. Recent test jobs gained 317 to 340 trace lines each, amounting to roughly 8,000 lines across a full workflow. The scripts already print the useful commands, selected list files, and final results. Drop global xtrace from run.sh, prepare-bpf-selftests.sh, and run-bpf-selftests.sh while retaining errexit, nounset, and pipefail. The focused xtrace around veristat commands remains. Assisted-by: Codex:GPT-5 Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> --------- Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
1 parent 6cdfb2d commit d46865c

23 files changed

Lines changed: 116 additions & 64 deletions

run-vmtest/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,24 @@ hung tasks and lockups. A hit adds a `kernel_splats` row to `exitstatus`, which
4747
turns the run red like any other failing test group. Anything fatal panics the
4848
VM instead, and fails the job on its own.
4949

50-
The check runs for the default suite or when the requested runners include
51-
`test_progs`. Veristat-only runs skip it.
50+
Leave both splat list files absent to disable detection.
5251

5352
The action carries no patterns. What a splat is, and what is benign, is policy
5453
that changes per arch and per kernel, so it lives with the configs. Two files
5554
of extended regexes, one per line, `#` comments and blank lines ignored, named
5655
by `run-vmtest.env` next to the allow and denylists:
5756

58-
* `SPLAT_DENYLIST_FILE` - a matching dmesg line is a splat. **Required.**
57+
* `SPLAT_DENYLIST_FILE` - a matching dmesg line is a splat.
5958
* `SPLAT_ALLOWLIST_FILE` - a matching splat line is ignored. Optional.
6059

61-
The denylist is required on purpose: with no patterns there is no check, so a
62-
missing or empty file fails the run rather than reporting a clean log.
60+
If either file exists, the denylist must exist and contain at least one
61+
pattern.
6362

6463
See `ci/vmtest/configs/SPLAT_DENYLIST` for the set BPF CI uses.
6564

66-
`dmesg.txt` is written to the output dir and uploaded as the `kernel-log-*`
67-
artifact, so the full log is always one click away.
65+
On failure, matching kernel log context is printed in the job log. `dmesg.txt`
66+
is also written to the output dir and uploaded as the `kernel-log-*` artifact
67+
for the full log.
6868

6969
## run-vmtest.env
7070

run-vmtest/check-kernel-splats.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
# config repo rather than here:
88
#
99
# SPLAT_DENYLIST_FILE extended regexes; a matching dmesg line is a splat.
10-
# Required: with no patterns there is no check, so a
11-
# missing file fails the run instead of passing it.
10+
# Required if either splat list file exists.
1211
# SPLAT_ALLOWLIST_FILE extended regexes; a matching splat line is ignored.
1312
# Optional: no file means no exceptions.
1413
#
1514
# `#` comments and blank lines are ignored in both. See run-vmtest.env in the
1615
# repo that owns $VMTEST_CONFIGS.
1716
#
18-
# The whole log is written to dmesg.txt, which the workflow uploads.
17+
# The whole log is written to dmesg.txt, which the workflow uploads. A short
18+
# excerpt around unallowlisted hits is written next to the status file so the
19+
# host can print it after closing the folded VM log.
1920
#
2021
# $1 - log file to scan instead of running dmesg (used by the unit tests)
2122

@@ -27,11 +28,20 @@ STATUS_FILE=${STATUS_FILE:-/mnt/vmtest/exitstatus}
2728
OUTPUT_DIR=${OUTPUT_DIR:-/mnt/vmtest}
2829
SPLAT_DENYLIST_FILE=${SPLAT_DENYLIST_FILE:-}
2930
SPLAT_ALLOWLIST_FILE=${SPLAT_ALLOWLIST_FILE:-}
31+
SPLAT_LOG_FILE=${SPLAT_LOG_FILE:-"$(dirname "${STATUS_FILE}")/kernel_splats.log"}
32+
33+
rm -f "${SPLAT_LOG_FILE}"
34+
35+
if [ ! -e "${SPLAT_DENYLIST_FILE}" ] && [ ! -e "${SPLAT_ALLOWLIST_FILE}" ]; then
36+
echo "Skipping kernel splat check: no allowlist or denylist files found"
37+
exit 0
38+
fi
3039

3140
# Fail the row and stop. Also used when the scan cannot run: a check that is
3241
# not working must not look like a clean log.
3342
fail_check() {
3443
echo "$1"
44+
printf '%s\n' "$1" > "${SPLAT_LOG_FILE}"
3545
echo "kernel_splats:1" >> "${STATUS_FILE}"
3646
foldable end kernel_splats
3747
exit 0
@@ -78,5 +88,8 @@ if [ -z "${hits}" ]; then
7888
fi
7989

8090
echo "kernel_splats:1" >> "${STATUS_FILE}"
81-
grep -nC 30 -E -f <(printf '%s\n' "${deny}") "${log}" || true
82-
echo "::error title=kernel_splats::kernel splat detected, see the dmesg.txt artifact"
91+
first_hit=${hits%%$'\n'*}
92+
{
93+
printf 'kernel splat detected: %s\n' "${first_hit}"
94+
grep -nC 30 -F -f <(printf '%s\n' "${hits}") "${log}" || true
95+
} > "${SPLAT_LOG_FILE}"

run-vmtest/prepare-bpf-selftests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
set -xeuo pipefail
3+
set -euo pipefail
44

55
if [[ -z "${SELFTESTS_BPF_ALLOWLIST_FILES:-}" && -z "${SELFTESTS_BPF_DENYLIST_FILES:-}" ]]; then
66
exit 0

run-vmtest/run-bpf-selftests.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# Runners passed as arguments are executed. In case of no arguments,
1313
# all test runners are executed.
1414

15-
set -xeuo pipefail
15+
set -euo pipefail
1616

1717
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
1818
source "${SCRIPT_DIR}/helpers.sh"
@@ -178,8 +178,4 @@ else
178178
done
179179
fi
180180

181-
if [ ${#TEST_NAMES[@]} -eq 0 ] || [[ "${TEST_NAMES[*]}" == *test_progs* ]]; then
182-
"${SCRIPT_DIR}/check-kernel-splats.sh"
183-
else
184-
echo "Skipping kernel splat check: test_progs not requested"
185-
fi
181+
"${SCRIPT_DIR}/check-kernel-splats.sh"

run-vmtest/run.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
set -xeuo pipefail
3+
set -euo pipefail
44
trap 'exit 2' ERR
55

66
source "${GITHUB_ACTION_PATH}/../helpers.sh"
@@ -117,6 +117,17 @@ rm -f $VMTEST_TOML
117117

118118
foldable end vmtest
119119

120+
if grep -q '^kernel_splats:1$' exitstatus; then
121+
splat_error="kernel splat check failed"
122+
if [[ -s kernel_splats.log ]]; then
123+
cat kernel_splats.log
124+
splat_error=$(head -n 1 kernel_splats.log)
125+
fi
126+
splat_error=${splat_error//'%'/'%25'}
127+
splat_error=${splat_error//$'\r'/'%0D'}
128+
printf '::error title=kernel_splats::%s\n' "${splat_error}"
129+
fi
130+
120131
foldable start collect_status "Collecting exit status"
121132

122133
exitfile="$(cat exitstatus 2>/dev/null)"

run-vmtest/tests/check_kernel_splats/cases/kasan/expected-output.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,3 @@
22
Splat denylist: $VMTEST_CONFIGS/SPLAT_DENYLIST
33
Splat allowlist: $VMTEST_CONFIGS/SPLAT_ALLOWLIST
44
::endgroup::
5-
1-[ 0.000000] Linux version 6.5.0
6-
2-[ 20.000000] ==================================================================
7-
3:[ 20.000001] BUG: KASAN: slab-use-after-free in foo+0x42/0x100
8-
4-[ 20.000002] Read of size 8 at addr ffff888100001234 by task test_progs/123
9-
5-[ 20.000003]
10-
6-[ 20.000004] CPU: 0 PID: 123 Comm: test_progs
11-
7-[ 20.000005] Call Trace:
12-
8-[ 20.000006] <TASK>
13-
9-[ 20.000007] dump_stack_lvl+0x60/0x80
14-
10-[ 20.000008] print_report+0xc4/0x630
15-
11-[ 20.000009] kasan_report+0xb6/0xf0
16-
12-[ 20.000010] </TASK>
17-
13-[ 20.000011] ==================================================================
18-
::error title=kernel_splats::kernel splat detected, see the dmesg.txt artifact
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
kernel splat detected: [ 20.000001] BUG: KASAN: slab-use-after-free in foo+0x42/0x100
2+
1-[ 0.000000] Linux version 6.5.0
3+
2-[ 20.000000] ==================================================================
4+
3:[ 20.000001] BUG: KASAN: slab-use-after-free in foo+0x42/0x100
5+
4-[ 20.000002] Read of size 8 at addr ffff888100001234 by task test_progs/123
6+
5-[ 20.000003]
7+
6-[ 20.000004] CPU: 0 PID: 123 Comm: test_progs
8+
7-[ 20.000005] Call Trace:
9+
8-[ 20.000006] <TASK>
10+
9-[ 20.000007] dump_stack_lvl+0x60/0x80
11+
10-[ 20.000008] print_report+0xc4/0x630
12+
11-[ 20.000009] kasan_report+0xb6/0xf0
13+
12-[ 20.000010] </TASK>
14+
13-[ 20.000011] ==================================================================
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
WARNING: CPU: 0 PID: 100 at kernel/sched/core\.c:1234
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[ 0.000000] Linux version 6.5.0
2+
[ 10.000000] WARNING: CPU: 0 PID: 100 at kernel/sched/core.c:1234 allowed+0x1/0x2
3+
[ 10.000001] Call Trace:
4+
[ 11.000000] BUG: KASAN: slab-out-of-bounds in real_splat+0x3/0x4
5+
[ 11.000001] Read of size 8 at addr ffff888000000000 by task test_progs/9
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export SPLAT_ALLOWLIST_FILE="${CASE_DIR}/allowlist.txt"

0 commit comments

Comments
 (0)