Skip to contentSkip to conversation

KVM: selftests: Fix core dump in rseq_test

PATCH Applied Gavin Shan 2 participants 3 messages Nov 24, 2025 – Dec 2, 2025

Subsystems (3)
lore
Share & tools
lore

Gavin Shan

author
#0 lore raw

PATCH 1/1 KVM: selftests: Fix core dump in rseq_test

In commit 0297cdc12a87 ("KVM: selftests: Add option to rseq test to override /dev/cpu_dma_latency"), a 'break' is missed before the option 'l' in the argument parsing loop, which leads to an unexpected core dump in atoi_paranoid(). It tries to get the latency from non-existent argument.

host$ ./rseq_test -u
Random seed: 0x6b8b4567
Segmentation fault (core dumped)

Add a 'break' before the option 'l' in the argument parsing loop to avoid the unexpected core dump.

Fixes 0297cdc12a87 ("KVM: selftests: Add option to rseq test to override /dev/cpu_dma_latency")
Cc [email protected] # v6.15+
---
 tools/testing/selftests/kvm/rseq_test.c | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/kvm/rseq_test.c +1 -0
index 1375fca80bcdb..f80ad6b47d16b 100644
@@ -215,6 +215,7 @@ int main(int argc, char *argv[])
 		switch (opt) {
 		case 'u':
 			skip_sanity_check = true;
+			break;
 		case 'l':
 			latency = atoi_paranoid(optarg);
 			break;
Signature · 1 line
2.51.1
author
#1 lore raw

Hi Sean,

Quoted 13 lines · Gavin Shan

In commit 0297cdc12a87 ("KVM: selftests: Add option to rseq test to override /dev/cpu_dma_latency"), a 'break' is missed before the option 'l' in the argument parsing loop, which leads to an unexpected core dump in atoi_paranoid(). It tries to get the latency from non-existent argument.

host$ ./rseq_test -u
Random seed: 0x6b8b4567
Segmentation fault (core dumped)

Add a 'break' before the option 'l' in the argument parsing loop to avoid the unexpected core dump.

Quoted 7 lines
Fixes 0297cdc12a87 ("KVM: selftests: Add option to rseq test to override /dev/cpu_dma_latency")
Cc [email protected] # v6.15+
---
  tools/testing/selftests/kvm/rseq_test.c | 1 +
  1 file changed, 1 insertion(+)

Could you help to take a look when getting a chance? :)

Thanks,
Gavin

Quoted 12 lines
tools/testing/selftests/kvm/rseq_test.c +1 -0
index 1375fca80bcdb..f80ad6b47d16b 100644
@@ -215,6 +215,7 @@ int main(int argc, char *argv[])
  		switch (opt) {
  		case 'u':
  			skip_sanity_check = true;
+			break;
  		case 'l':
  			latency = atoi_paranoid(optarg);
  			break;
reviewer Applied
#2 lore raw
In reply to Gavin Shan
Quoted 11 lines · Gavin Shan

In commit 0297cdc12a87 ("KVM: selftests: Add option to rseq test to override /dev/cpu_dma_latency"), a 'break' is missed before the option 'l' in the argument parsing loop, which leads to an unexpected core dump in atoi_paranoid(). It tries to get the latency from non-existent argument.

host$ ./rseq_test -u
Random seed: 0x6b8b4567
Segmentation fault (core dumped)

[...]

Applied to kvm-x86 fixes, with a massaged shortlog. FWIW, I'm planning on sending Paolo a fixes pull request later this week, so this should make it into 6.19-rc1.

[1/1] KVM: selftests: Add missing "break" in rseq_test's param parsing

      https://github.com/kvm-x86/linux/commit/1b9439c933b5

--
https://github.com/kvm-x86/linux/tree/next