vl: fix -sandbox parsing crash when seccomp support is disabled
PATCH 1/1 vl: fix -sandbox parsing crash when seccomp support is disabled
$ ./x86_64-softmmu/qemu-system-x86_64 -sandbox off qemu-system-x86_64: -sandbox off: There is no option group 'sandbox' Segmentation fault
Commit 5780760f5e ("seccomp: check TSYNC host capability") wrapped one use of the sandbox option group to produce a sensible error, it didn't do the same for another call to qemu_opts_parse_noisily():
(gdb) bt
at util/qemu-option.c:829
#0 0x00000000105b36d8 in opts_parse (list=0x0, params=0x3ffffffffab5 "off", permit_abbrev=true, defaults=false, errp=0x3ffffffff080)
at util/qemu-option.c:829
#1 0x00000000105b3b74 in qemu_opts_parse_noisily (list=<optimized out>, params=<optimized out>, permit_abbrev=<optimized out>) at util/qemu-option.c:890
#2 0x0000000010024964 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:3589--- vl.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
vl.c +10 -8
@@ -3866,17 +3866,19 @@ int main(int argc, char **argv, char **envp) qtest_log = optarg;break ;case QEMU_OPTION_sandbox: -#ifdef CONFIG_SECCOMP - opts =qemu_opts_parse_noisily (qemu_find_opts ("sandbox" ), - optarg, true); + olist =qemu_find_opts ("sandbox" ); +if (!olist) { +#ifndef CONFIG_SECCOMP +error_report ("-sandbox support is not enabled " +"in this QEMU binary" ); +#endif +exit (1 ); + } + + opts =qemu_opts_parse_noisily (olist, optarg, true);if (!opts) {exit (1 ); } -#else -error_report ("-sandbox support is not enabled " -"in this QEMU binary" ); -exit (1 ); -#endif break ;case QEMU_OPTION_add_fd:#ifndef _WIN32
Signature · 1 line
2.21.0.777.g83232e3864
Quoted 15 lines · Marc-André Lureau
$ ./x86_64-softmmu/qemu-system-x86_64 -sandbox off qemu-system-x86_64: -sandbox off: There is no option group 'sandbox' Segmentation faultCommit
5780760f5e("seccomp: check TSYNC host capability") wrapped one use of the sandbox option group to produce a sensible error, it didn't do the same for another call toqemu_opts_parse_noisily():(gdb) bt
at util/qemu-option.c:829 #0 0x00000000105b36d8 in opts_parse (list=0x0, params=0x3ffffffffab5 "off", permit_abbrev=true, defaults=false, errp=0x3ffffffff080) at util/qemu-option.c:829 #1 0x00000000105b3b74 in qemu_opts_parse_noisily (list=<optimized out>, params=<optimized out>, permit_abbrev=<optimized out>) at util/qemu-option.c:890 #2 0x0000000010024964 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:3589
Quoted 4 lines
Fixes 5780760f5ea6163939a5dabe7427318b4f07d1a2Signed-off-by Marc-André Lureau <[email protected]>
Quoted 37 lines
--- vl.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)vl.c +10
-8@@ -3866,17 +3866,19 @@ int main(int argc, char **argv, char **envp) qtest_log = optarg;break ;case QEMU_OPTION_sandbox: -#ifdef CONFIG_SECCOMP - opts =qemu_opts_parse_noisily (qemu_find_opts ("sandbox" ), - optarg, true); + olist =qemu_find_opts ("sandbox" ); +if (!olist) { +#ifndef CONFIG_SECCOMP +error_report ("-sandbox support is not enabled " +"in this QEMU binary" ); +#endif +exit (1 ); + } + + opts =qemu_opts_parse_noisily (olist, optarg, true);if (!opts) {exit (1 ); } -#else -error_report ("-sandbox support is not enabled " -"in this QEMU binary" ); -exit (1 ); -#endif break ;case QEMU_OPTION_add_fd:#ifndef _WIN32
Quoted 28 lines · Marc-André Lureau
$ ./x86_64-softmmu/qemu-system-x86_64 -sandbox off qemu-system-x86_64: -sandbox off: There is no option group 'sandbox' Segmentation faultCommit
5780760f5e("seccomp: check TSYNC host capability") wrapped one use of the sandbox option group to produce a sensible error, it didn't do the same for another call toqemu_opts_parse_noisily():(gdb) bt
at util/qemu-option.c:829 #0 0x00000000105b36d8 in opts_parse (list=0x0, params=0x3ffffffffab5 "off", permit_abbrev=true, defaults=false, errp=0x3ffffffff080) at util/qemu-option.c:829 #1 0x00000000105b3b74 in qemu_opts_parse_noisily (list=<optimized out>, params=<optimized out>, permit_abbrev=<optimized out>) at util/qemu-option.c:890 #2 0x0000000010024964 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:3589Fixes 5780760f5ea6163939a5dabe7427318b4f07d1a2Signed-off-by Marc-André Lureau <[email protected]>--- vl.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)vl.c +0
-0
vl.c int main(int argc, char **argv, char **envp) · line 3871
Quoted 9 lines
vl.c +3
-3@@ -3866,17 +3866,19 @@ int main(int argc, char **argv, char **envp) qtest_log = optarg;break ;case QEMU_OPTION_sandbox: -#ifdef CONFIG_SECCOMP - opts =qemu_opts_parse_noisily (qemu_find_opts ("sandbox" ), - optarg, true); + olist =qemu_find_opts ("sandbox" ); +if (!olist) { +#ifndef CONFIG_SECCOMP
Why do you move the #ifdef? We have two separate error cases here. And it seems better no to check for "-sandbox" when seccomp is disabled.
Thanks,
Laurent
Hi
Quoted 34 lines · Laurent Vivier
Quoted 32 lines · Marc-André Lureau
$ ./x86_64-softmmu/qemu-system-x86_64 -sandbox off qemu-system-x86_64: -sandbox off: There is no option group 'sandbox' Segmentation faultCommit
5780760f5e("seccomp: check TSYNC host capability") wrapped one use of the sandbox option group to produce a sensible error, it didn't do the same for another call toqemu_opts_parse_noisily():(gdb) bt
at util/qemu-option.c:829 #0 0x00000000105b36d8 in opts_parse (list=0x0, params=0x3ffffffffab5 "off", permit_abbrev=true, defaults=false, errp=0x3ffffffff080) at util/qemu-option.c:829 #1 0x00000000105b3b74 in qemu_opts_parse_noisily (list=<optimized out>, params=<optimized out>, permit_abbrev=<optimized out>) at util/qemu-option.c:890 #2 0x0000000010024964 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:3589Fixes 5780760f5ea6163939a5dabe7427318b4f07d1a2Signed-off-by Marc-André Lureau <[email protected]>--- vl.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)vl.c +0
-1@@ -3866,17 +3866,19 @@ int main(int argc, char **argv, char **envp) qtest_log = optarg;break ;case QEMU_OPTION_sandbox: -#ifdef CONFIG_SECCOMP
Quoted 8 lines
vl.c int main(int argc, char **argv, char **envp) · line 3871
Quoted 5 lines
vl.c +3
-2- opts =qemu_opts_parse_noisily (qemu_find_opts ("sandbox" ), - optarg, true); + olist =qemu_find_opts ("sandbox" ); +if (!olist) { +#ifndef CONFIG_SECCOMP Why do you move the #ifdef? We have two separate error cases here. And it seems better no to check for "-sandbox" when seccomp is disabled.
I tried to remove the #ifdef altogether to simplify the code, then realized the error message could be useful.
I don't think it's a problem to lookup "-sandbox" when seccomp is disabled.
Signature · 1 line
Marc-André Lureau
Laurent Vivier
Reviewed-byQuoted 46 lines · Marc-André Lureau
Hi
Quoted 34 lines · Laurent Vivier
Quoted 32 lines · Marc-André Lureau
$ ./x86_64-softmmu/qemu-system-x86_64 -sandbox off qemu-system-x86_64: -sandbox off: There is no option group 'sandbox' Segmentation faultCommit
5780760f5e("seccomp: check TSYNC host capability") wrapped one use of the sandbox option group to produce a sensible error, it didn't do the same for another call toqemu_opts_parse_noisily():(gdb) bt
at util/qemu-option.c:829 #0 0x00000000105b36d8 in opts_parse (list=0x0, params=0x3ffffffffab5 "off", permit_abbrev=true, defaults=false, errp=0x3ffffffff080) at util/qemu-option.c:829 #1 0x00000000105b3b74 in qemu_opts_parse_noisily (list=<optimized out>, params=<optimized out>, permit_abbrev=<optimized out>) at util/qemu-option.c:890 #2 0x0000000010024964 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:3589Fixes 5780760f5ea6163939a5dabe7427318b4f07d1a2Signed-off-by Marc-André Lureau <[email protected]>--- vl.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)vl.c +0
-1@@ -3866,17 +3866,19 @@ int main(int argc, char **argv, char **envp) qtest_log = optarg;break ;case QEMU_OPTION_sandbox: -#ifdef CONFIG_SECCOMP Quoted 8 lines
vl.c int main(int argc, char **argv, char **envp) · line 3871
Quoted 5 lines
vl.c +3
-2- opts =qemu_opts_parse_noisily (qemu_find_opts ("sandbox" ), - optarg, true); + olist =qemu_find_opts ("sandbox" ); +if (!olist) { +#ifndef CONFIG_SECCOMP Why do you move the #ifdef? We have two separate error cases here. And it seems better no to check for "-sandbox" when seccomp is disabled.
Quoted 5 lines
I tried to remove the #ifdef altogether to simplify the code, then realized the error message could be useful.
I don't think it's a problem to lookup "-sandbox" when seccomp is disabled.
ok, so:
Quoted 15 lines · Marc-André Lureau
$ ./x86_64-softmmu/qemu-system-x86_64 -sandbox off qemu-system-x86_64: -sandbox off: There is no option group 'sandbox' Segmentation faultCommit
5780760f5e("seccomp: check TSYNC host capability") wrapped one use of the sandbox option group to produce a sensible error, it didn't do the same for another call toqemu_opts_parse_noisily():(gdb) bt
at util/qemu-option.c:829 #0 0x00000000105b36d8 in opts_parse (list=0x0, params=0x3ffffffffab5 "off", permit_abbrev=true, defaults=false, errp=0x3ffffffff080) at util/qemu-option.c:829 #1 0x00000000105b3b74 in qemu_opts_parse_noisily (list=<optimized out>, params=<optimized out>, permit_abbrev=<optimized out>) at util/qemu-option.c:890 #2 0x0000000010024964 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:3589
Quoted 7 lines
Fixes 5780760f5ea6163939a5dabe7427318b4f07d1a2Signed-off-by Marc-André Lureau <[email protected]>--- vl.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
This fixes the crash for me, so
Signature · 1 line
Andrea Bolognani / Red Hat / Virtualization
Paolo Bonzini
AppliedQuoted 46 lines · Marc-André Lureau
$ ./x86_64-softmmu/qemu-system-x86_64 -sandbox off qemu-system-x86_64: -sandbox off: There is no option group 'sandbox' Segmentation faultCommit
5780760f5e("seccomp: check TSYNC host capability") wrapped one use of the sandbox option group to produce a sensible error, it didn't do the same for another call toqemu_opts_parse_noisily():(gdb) bt
at util/qemu-option.c:829 #0 0x00000000105b36d8 in opts_parse (list=0x0, params=0x3ffffffffab5 "off", permit_abbrev=true, defaults=false, errp=0x3ffffffff080) at util/qemu-option.c:829 #1 0x00000000105b3b74 in qemu_opts_parse_noisily (list=<optimized out>, params=<optimized out>, permit_abbrev=<optimized out>) at util/qemu-option.c:890 #2 0x0000000010024964 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:3589Fixes 5780760f5ea6163939a5dabe7427318b4f07d1a2Signed-off-by Marc-André Lureau <[email protected]>--- vl.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)vl.c +10
-3@@ -3866,17 +3866,19 @@ int main(int argc, char **argv, char **envp) qtest_log = optarg;break ;case QEMU_OPTION_sandbox: -#ifdef CONFIG_SECCOMP - opts =qemu_opts_parse_noisily (qemu_find_opts ("sandbox" ), - optarg, true); + olist =qemu_find_opts ("sandbox" ); +if (!olist) { +#ifndef CONFIG_SECCOMP +error_report ("-sandbox support is not enabled " +"in this QEMU binary" ); +#endif +exit (1 ); + } + + opts =qemu_opts_parse_noisily (olist, optarg, true);if (!opts) {
vl.c int main(int argc, char **argv, char **envp) · line 3884
Quoted 10 lines
vl.c +0
-5exit (1 ); } -#else -error_report ("-sandbox support is not enabled " -"in this QEMU binary" ); -exit (1 ); -#endif break ;case QEMU_OPTION_add_fd:#ifndef _WIN32
Queued, thanks.
Paolo
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the asan build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1 === TEST SCRIPT END ===
The full log is available at
http://patchew.org/logs/[email protected]/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]