[PATCH] KVM: selftests: Fix core dump in rseq_test

Gavin Shan posted 1 patch 1 week ago
tools/testing/selftests/kvm/rseq_test.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] KVM: selftests: Fix core dump in rseq_test
Posted by Gavin Shan 1 week ago
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: stable@vger.kernel.org # v6.15+
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
 tools/testing/selftests/kvm/rseq_test.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/kvm/rseq_test.c b/tools/testing/selftests/kvm/rseq_test.c
index 1375fca80bcdb..f80ad6b47d16b 100644
--- a/tools/testing/selftests/kvm/rseq_test.c
+++ b/tools/testing/selftests/kvm/rseq_test.c
@@ -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;
-- 
2.51.1
Re: [PATCH] KVM: selftests: Fix core dump in rseq_test
Posted by Gavin Shan an hour ago
Hi Sean,

On 11/24/25 3:04 PM, Gavin Shan wrote:
> 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: stable@vger.kernel.org # v6.15+
> Signed-off-by: Gavin Shan <gshan@redhat.com>
> ---
>   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

> diff --git a/tools/testing/selftests/kvm/rseq_test.c b/tools/testing/selftests/kvm/rseq_test.c
> index 1375fca80bcdb..f80ad6b47d16b 100644
> --- a/tools/testing/selftests/kvm/rseq_test.c
> +++ b/tools/testing/selftests/kvm/rseq_test.c
> @@ -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;