Skip to contentSkip to conversation

Bug: Sandbox: libvirt breakdowns qemu guest

PATCH Superseded Yi Min Zhao 5 participants 21 messages May 15, 2018 – May 28, 2018

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Bug: Sandbox: libvirt breakdowns qemu guest

1. Problem Description
======================
If QEMU is built without seccomp support, 'elevateprivileges' remains compiled. This option of sandbox is treated as an indication for seccomp blacklist support in libvirt. This behavior is introduced by the libvirt commits 31ca6a5 and 3527f9d. It would make libvirt build wrong QEMU cmdline, and then the guest startup would fail.

2. Libvirt Log
==============
qemu-system-s390x: -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
resourcecontrol=deny: seccomp support is disabled

3. Fixup
========
Compile the code related to sandbox only when CONFIG_SECCOMP is defined.

Yi Min Zhao (1):
sandbox: disable -sandbox if CONFIG_SECCOMP undefined

 vl.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
Signature · 1 line
Yi Min
#1 lore raw

PATCH v2 1/1 sandbox: disable -sandbox if CONFIG_SECCOMP undefined

If CONFIG_SECCOMP is undefined, the option 'elevateprivileges' remains compiled. This would make libvirt set the corresponding capability and then trigger the guest startup fails. So this patch excludes the code regarding seccomp staff if CONFIG_SECCOMP is undefined.

---
 vl.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
vl.c +8 -5
index 806eec2ef6..b22d158f5f 100644
@@ -257,6 +257,7 @@ static QemuOptsList qemu_rtc_opts = {
     },
 };
 
+#ifdef CONFIG_SECCOMP
 static QemuOptsList qemu_sandbox_opts = {
     .name = "sandbox",
     .implied_opt_name = "enable",
@@ -285,6 +286,7 @@ static QemuOptsList qemu_sandbox_opts = {
         { /* end of list */ }
     },
 };
+#endif
 
 static QemuOptsList qemu_option_rom_opts = {
     .name = "option-rom",
@@ -1041,10 +1043,10 @@ static int bt_parse(const char *opt)
     return 1;
 }
 
+#ifdef CONFIG_SECCOMP
 static int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
 {
     if (qemu_opt_get_bool(opts, "enable", false)) {
-#ifdef CONFIG_SECCOMP
         uint32_t seccomp_opts = QEMU_SECCOMP_SET_DEFAULT
                 | QEMU_SECCOMP_SET_OBSOLETE;
         const char *value = NULL;
@@ -1114,14 +1116,11 @@ static int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
                          "in the kernel");
             return -1;
         }
-#else
-        error_report("seccomp support is disabled");
-        return -1;
-#endif
     }
 
     return 0;
 }
+#endif
 
 static int parse_name(void *opaque, QemuOpts *opts, Error **errp)
 {
@@ -3074,7 +3073,9 @@ int main(int argc, char **argv, char **envp)
     qemu_add_opts(&qemu_mem_opts);
     qemu_add_opts(&qemu_smp_opts);
     qemu_add_opts(&qemu_boot_opts);
+#ifdef CONFIG_SECCOMP
     qemu_add_opts(&qemu_sandbox_opts);
+#endif
     qemu_add_opts(&qemu_add_fd_opts);
     qemu_add_opts(&qemu_object_opts);
     qemu_add_opts(&qemu_tpmdev_opts);
@@ -4071,10 +4072,12 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
+#ifdef CONFIG_SECCOMP
     if (qemu_opts_foreach(qemu_find_opts("sandbox"),
                           parse_sandbox, NULL, NULL)) {
         exit(1);
     }
+#endif
 
     if (qemu_opts_foreach(qemu_find_opts("name"),
                           parse_name, NULL, NULL)) {
Signature · 1 line
Yi Min
Reviewed-by on v2 1/1
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 3 lines · Yi Min Zhao

If CONFIG_SECCOMP is undefined, the option 'elevateprivileges' remains compiled. This would make libvirt set the corresponding capability and then trigger the guest startup fails. So this patch excludes the code

s/trigger the guest startup fails/trigger failure during guest startup/

Quoted 1 line

regarding seccomp staff if CONFIG_SECCOMP is undefined.

s/staff/command line options/

Quoted 6 lines
---
  vl.c | 13 ++++++++-----
  1 file changed, 8 insertions(+), 5 deletions(-)

A maintainer can touch up the commit message, so:

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#3 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 12 lines · Eric Blake
Quoted 3 lines · Yi Min Zhao

If CONFIG_SECCOMP is undefined, the option 'elevateprivileges' remains compiled. This would make libvirt set the corresponding capability and then trigger the guest startup fails. So this patch excludes the code

s/trigger the guest startup fails/trigger failure during guest startup/

Quoted 1 line

regarding seccomp staff if CONFIG_SECCOMP is undefined.

s/staff/command line options/

Quoted 1 line
Quoted 9 lines
Quoted 5 lines

---
  vl.c | 13 ++++++++-----

  1 file changed, 8 insertions(+), 5 deletions(-)

A maintainer can touch up the commit message, so:

Thanks for your comments! Have updated commit msg.

#4 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

In reply to Eric Blake

Add Paolo to CC list. @Paolo, expect your comment. Thanks very much!

Quoted 21 lines · Eric Blake
Quoted 3 lines · Yi Min Zhao

If CONFIG_SECCOMP is undefined, the option 'elevateprivileges' remains compiled. This would make libvirt set the corresponding capability and then trigger the guest startup fails. So this patch excludes the code

s/trigger the guest startup fails/trigger failure during guest startup/

Quoted 1 line

regarding seccomp staff if CONFIG_SECCOMP is undefined.

s/staff/command line options/

Quoted 6 lines

---
  vl.c | 13 ++++++++-----

  1 file changed, 8 insertions(+), 5 deletions(-)

A maintainer can touch up the commit message, so:

#5 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

In reply to Yi Min Zhao
Quoted 4 lines · Yi Min Zhao

If CONFIG_SECCOMP is undefined, the option 'elevateprivileges' remains compiled. This would make libvirt set the corresponding capability and then trigger the guest startup fails. So this patch excludes the code regarding seccomp staff if CONFIG_SECCOMP is undefined.

Just a sugestion for the next patch you send: If it's a single patch, you don't need to format it with a cover-letter. Just put all the description in the body, or if you need to add a text that shouldn't be included in the commit message, just add it after the "---" after Signed-off-by.

Quoted 39 lines
---
 vl.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
vl.c +3 -1
index 806eec2ef6..b22d158f5f 100644
@@ -257,6 +257,7 @@ static QemuOptsList qemu_rtc_opts = {
     },
 };
 
+#ifdef CONFIG_SECCOMP
 static QemuOptsList qemu_sandbox_opts = {
     .name = "sandbox",
     .implied_opt_name = "enable",
@@ -285,6 +286,7 @@ static QemuOptsList qemu_sandbox_opts = {
         { /* end of list */ }
     },
 };
+#endif
 
 static QemuOptsList qemu_option_rom_opts = {
     .name = "option-rom",
@@ -1041,10 +1043,10 @@ static int bt_parse(const char *opt)
     return 1;
 }
 
+#ifdef CONFIG_SECCOMP
 static int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
 {
     if (qemu_opt_get_bool(opts, "enable", false)) {
-#ifdef CONFIG_SECCOMP
         uint32_t seccomp_opts = QEMU_SECCOMP_SET_DEFAULT
                 | QEMU_SECCOMP_SET_OBSOLETE;
         const char *value = NULL;

vl.c static int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp) · line 1120

Quoted 7 lines
vl.c +0 -4
@@ -1114,14 +1116,11 @@ static int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
                          "in the kernel");
             return -1;
         }
-#else
-        error_report("seccomp support is disabled");
-        return -1;
-#endif

Any reason not to keep the error message on the new #endif location?

Quoted 34 lines
vl.c +5 -0
     }
 
     return 0;
 }
+#endif
 
 static int parse_name(void *opaque, QemuOpts *opts, Error **errp)
 {
@@ -3074,7 +3073,9 @@ int main(int argc, char **argv, char **envp)
     qemu_add_opts(&qemu_mem_opts);
     qemu_add_opts(&qemu_smp_opts);
     qemu_add_opts(&qemu_boot_opts);
+#ifdef CONFIG_SECCOMP
     qemu_add_opts(&qemu_sandbox_opts);
+#endif
     qemu_add_opts(&qemu_add_fd_opts);
     qemu_add_opts(&qemu_object_opts);
     qemu_add_opts(&qemu_tpmdev_opts);
@@ -4071,10 +4072,12 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
+#ifdef CONFIG_SECCOMP
     if (qemu_opts_foreach(qemu_find_opts("sandbox"),
                           parse_sandbox, NULL, NULL)) {
         exit(1);
     }
+#endif
 
     if (qemu_opts_foreach(qemu_find_opts("name"),
                           parse_name, NULL, NULL)) {
Signature · 1 line
Yi Min

I just wanted a review from Ján, since he is the author of the original libvirt patch. Does this breaks libvirt logic in any way? If not, ACK on this patch.

#6 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 9 lines · Eduardo Otubo
Quoted 4 lines · Yi Min Zhao

If CONFIG_SECCOMP is undefined, the option 'elevateprivileges' remains compiled. This would make libvirt set the corresponding capability and then trigger the guest startup fails. So this patch excludes the code regarding seccomp staff if CONFIG_SECCOMP is undefined.

Just a sugestion for the next patch you send: If it's a single patch, you don't need to format it with a cover-letter. Just put all the description in the body, or if you need to add a text that shouldn't be included in the commit message, just add it after the "---" after Signed-off-by.

OK. Thanks for your suggestion.

Quoted 39 lines
Quoted 39 lines
---
  vl.c | 13 ++++++++-----
  1 file changed, 8 insertions(+), 5 deletions(-)
vl.c +3 -1
index 806eec2ef6..b22d158f5f 100644
@@ -257,6 +257,7 @@ static QemuOptsList qemu_rtc_opts = {
      },
  };
 
+#ifdef CONFIG_SECCOMP
  static QemuOptsList qemu_sandbox_opts = {
      .name = "sandbox",
      .implied_opt_name = "enable",
@@ -285,6 +286,7 @@ static QemuOptsList qemu_sandbox_opts = {
          { /* end of list */ }
      },
  };
+#endif
 
  static QemuOptsList qemu_option_rom_opts = {
      .name = "option-rom",
@@ -1041,10 +1043,10 @@ static int bt_parse(const char *opt)
      return 1;
  }
 
+#ifdef CONFIG_SECCOMP
  static int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
  {
      if (qemu_opt_get_bool(opts, "enable", false)) {
-#ifdef CONFIG_SECCOMP
          uint32_t seccomp_opts = QEMU_SECCOMP_SET_DEFAULT
                  | QEMU_SECCOMP_SET_OBSOLETE;
          const char *value = NULL;
@@ -1114,14 +1116,11 @@ static int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp)
Quoted 8 lines

vl.c static int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp) · line 1120

Quoted 7 lines
vl.c +0 -4
                           "in the kernel");
              return -1;
          }
-#else
-        error_report("seccomp support is disabled");
-        return -1;
-#endif

Any reason not to keep the error message on the new #endif location?

If error report is originally wrapped in CONFIG_SECCOMP undefined. This patch excludes the entire function if CONFIG_SECCOMP is undefined. So the error report is not needed.

Quoted 30 lines
Quoted 30 lines
vl.c +5 -0
      }
 
      return 0;
  }
+#endif
 
  static int parse_name(void *opaque, QemuOpts *opts, Error **errp)
  {
@@ -3074,7 +3073,9 @@ int main(int argc, char **argv, char **envp)
      qemu_add_opts(&qemu_mem_opts);
      qemu_add_opts(&qemu_smp_opts);
      qemu_add_opts(&qemu_boot_opts);
+#ifdef CONFIG_SECCOMP
      qemu_add_opts(&qemu_sandbox_opts);
+#endif
      qemu_add_opts(&qemu_add_fd_opts);
      qemu_add_opts(&qemu_object_opts);
      qemu_add_opts(&qemu_tpmdev_opts);
@@ -4071,10 +4072,12 @@ int main(int argc, char **argv, char **envp)
          exit(1);
      }
 
+#ifdef CONFIG_SECCOMP
      if (qemu_opts_foreach(qemu_find_opts("sandbox"),
                            parse_sandbox, NULL, NULL)) {
          exit(1);
      }
+#endif
 
Quoted 9 lines
Quoted 5 lines
vl.c +0 -0
      if (qemu_opts_foreach(qemu_find_opts("name"),
                            parse_name, NULL, NULL)) {
Signature · 1 line
Yi Min

I just wanted a review from Ján, since he is the author of the original libvirt patch. Does this breaks libvirt logic in any way? If not, ACK on this patch.

OK.

#7 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

In reply to Eduardo Otubo
Quoted 29 lines · Eduardo Otubo
Quoted 4 lines · Yi Min Zhao

If CONFIG_SECCOMP is undefined, the option 'elevateprivileges' remains compiled. This would make libvirt set the corresponding capability and then trigger the guest startup fails. So this patch excludes the code regarding seccomp staff if CONFIG_SECCOMP is undefined.

Just a sugestion for the next patch you send: If it's a single patch, you don't need to format it with a cover-letter. Just put all the description in the body, or if you need to add a text that shouldn't be included in the commit message, just add it after the "---" after Signed-off-by.

Quoted 18 lines
---
 vl.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
vl.c +2 -0
@@ -4071,10 +4072,12 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
+#ifdef CONFIG_SECCOMP
     if (qemu_opts_foreach(qemu_find_opts("sandbox"),
                           parse_sandbox, NULL, NULL)) {
         exit(1);
     }
+#endif
 
Quoted 9 lines
Quoted 5 lines
vl.c +0 -1
     if (qemu_opts_foreach(qemu_find_opts("name"),
                           parse_name, NULL, NULL)) {
--

Yi Min

I just wanted a review from Ján, since he is the author of the original libvirt patch. Does this breaks libvirt logic in any way? If not, ACK on this patch.

Current libvirt logic assumes the -sandbox option is always present. (IIRC it was introduced in QEMU 1.1 and when we switched from help scraping to capability probing via QMP for QEMU 1.2, there was no way to detect it)

This patch fixes the usage of QEMU new enough for seccomp blacklist (where libvirt enables the sandbox by default),
but breaks the usage of QEMU with compiled out sandbox and setting
seccomp_sandbox = 0
in libvirt's qemu.conf:

error: internal error: process exited while connecting to monitor:
qemu-git: -sandbox off: There is no option group 'sandbox'

But now libvirt requires QEMU >= 1.5.0 which already supports query-command-line-options, so if you want the option gone completely --without-seccomp, I can add the code that probes for it and make seccomp_sandbox = 0 a no-op if it's compiled out.

Jano

#8 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 52 lines · Ján Tomko
Quoted 29 lines · Eduardo Otubo
Quoted 4 lines · Yi Min Zhao

If CONFIG_SECCOMP is undefined, the option 'elevateprivileges' remains compiled. This would make libvirt set the corresponding capability and then trigger the guest startup fails. So this patch excludes the code regarding seccomp staff if CONFIG_SECCOMP is undefined.

Just a sugestion for the next patch you send: If it's a single patch, you don't need to format it with a cover-letter. Just put all the description in the body, or if you need to add a text that shouldn't be included in the commit message, just add it after the "---" after Signed-off-by.

Quoted 18 lines
---
 vl.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
vl.c +2 -0
@@ -4071,10 +4072,12 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
+#ifdef CONFIG_SECCOMP
     if (qemu_opts_foreach(qemu_find_opts("sandbox"),
                           parse_sandbox, NULL, NULL)) {
         exit(1);
     }
+#endif
 
Quoted 9 lines
Quoted 5 lines
vl.c +0 -1
     if (qemu_opts_foreach(qemu_find_opts("name"),
                           parse_name, NULL, NULL)) {
--

Yi Min

I just wanted a review from Ján, since he is the author of the original libvirt patch. Does this breaks libvirt logic in any way? If not, ACK on this patch.

Current libvirt logic assumes the -sandbox option is always present. (IIRC it was introduced in QEMU 1.1 and when we switched from help scraping to capability probing via QMP for QEMU 1.2, there was no way to detect it)

This patch fixes the usage of QEMU new enough for seccomp blacklist (where libvirt enables the sandbox by default),
but breaks the usage of QEMU with compiled out sandbox and setting
seccomp_sandbox = 0
in libvirt's qemu.conf:

Quoted 8 lines

error: internal error: process exited while connecting to monitor:
qemu-git: -sandbox off: There is no option group 'sandbox'

But now libvirt requires QEMU >= 1.5.0 which already supports query-command-line-options, so if you want the option gone completely --without-seccomp, I can add the code that probes for it and make seccomp_sandbox = 0 a no-op if it's compiled out.

This looks like a good solution for the libvirt side. Can you add this support so we can merge this fix?

Thanks a lot,

Signature · 1 line
Eduardo Otubo
#9 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 20 lines · Eduardo Otubo
Quoted 19 lines · Ján Tomko
Quoted 17 lines · Eduardo Otubo
Quoted 4 lines · Yi Min Zhao

If CONFIG_SECCOMP is undefined, the option 'elevateprivileges' remains compiled. This would make libvirt set the corresponding capability and then trigger the guest startup fails. So this patch excludes the code regarding seccomp staff if CONFIG_SECCOMP is undefined.

Just a sugestion for the next patch you send: If it's a single patch, you don't need to format it with a cover-letter. Just put all the description in the body, or if you need to add a text that shouldn't be included in the commit message, just add it after the "---" after Signed-off-by.

Quoted 6 lines
---
 vl.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

[...]

Quoted 16 lines
Quoted 16 lines

Current libvirt logic assumes the -sandbox option is always present. (IIRC it was introduced in QEMU 1.1 and when we switched from help scraping to capability probing via QMP for QEMU 1.2, there was no way to detect it)

This patch fixes the usage of QEMU new enough for seccomp blacklist (where libvirt enables the sandbox by default),
but breaks the usage of QEMU with compiled out sandbox and setting
seccomp_sandbox = 0
in libvirt's qemu.conf:

error: internal error: process exited while connecting to monitor:
qemu-git: -sandbox off: There is no option group 'sandbox'

Quoted 8 lines
Quoted 4 lines

But now libvirt requires QEMU >= 1.5.0 which already supports query-command-line-options, so if you want the option gone completely --without-seccomp, I can add the code that probes for it and make seccomp_sandbox = 0 a no-op if it's compiled out.

This looks like a good solution for the libvirt side. Can you add this support so we can merge this fix?

Patches proposed:
https://www.redhat.com/archives/libvir-list/2018-May/msg01430.html

Jano

#10 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 51 lines · Ján Tomko
Quoted 26 lines · Eduardo Otubo
Quoted 25 lines · Ján Tomko
Quoted 2 lines · Eduardo Otubo
Quoted 1 line · Yi Min Zhao

If CONFIG_SECCOMP is undefined, the option 'elevateprivileges'

remains

Quoted 1 line
Quoted 1 line

compiled. This would make libvirt set the corresponding

capability and

Quoted 1 line
Quoted 1 line

then trigger the guest startup fails. So this patch excludes the

code

Quoted 3 lines
Quoted 1 line

regarding seccomp staff if CONFIG_SECCOMP is undefined.

Just a sugestion for the next patch you send: If it's a single

patch, you don't

Quoted 1 line

need to format it with a cover-letter. Just put all the

description in the body,

Quoted 1 line

or if you need to add a text that shouldn't be included in the

commit message,

Quoted 8 lines

just add it after the "---" after Signed-off-by.

Quoted 6 lines

---
  vl.c | 13 ++++++++-----

  1 file changed, 8 insertions(+), 5 deletions(-)

[...]

Quoted 21 lines
Quoted 20 lines

Current libvirt logic assumes the -sandbox option is always present. (IIRC it was introduced in QEMU 1.1 and when we switched from help scraping to capability probing via QMP for QEMU 1.2, there was no way to detect it)

This patch fixes the usage of QEMU new enough for seccomp blacklist (where libvirt enables the sandbox by default),
but breaks the usage of QEMU with compiled out sandbox and setting
 seccomp_sandbox = 0
in libvirt's qemu.conf:

error: internal error: process exited while connecting to monitor:
qemu-git: -sandbox off: There is no option group 'sandbox'

But now libvirt requires QEMU >= 1.5.0 which already supports query-command-line-options, so if you want the option gone completely --without-seccomp, I can add the code that probes for it and make seccomp_sandbox = 0 a no-op if it's compiled out.

Quoted 8 lines
Quoted 3 lines

This looks like a good solution for the libvirt side. Can you add this support so we can merge this fix?

Patches proposed:
https://www.redhat.com/archives/libvir-list/2018-May/msg01430.html

Jano

Thanks for your work!

Reviewed-by John Ferlan
#11 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 15 lines · Yi Min Zhao
Quoted 12 lines · Ján Tomko
Quoted 10 lines · Eduardo Otubo
Quoted 4 lines · Ján Tomko

But now libvirt requires QEMU >= 1.5.0 which already supports query-command-line-options, so if you want the option gone completely --without-seccomp, I can add the code that probes for it and make seccomp_sandbox = 0 a no-op if it's compiled out.

This looks like a good solution for the libvirt side. Can you add this support
so we can merge this fix?

Quoted 5 lines
Quoted 4 lines

Patches proposed:
https://www.redhat.com/archives/libvir-list/2018-May/msg01430.html

Jano

Thanks for your work!

Now pushed in libvirt master:
commit b87222a90919040c12fb6d7c8dcc20f944a66495

Author:     Ján Tomko <[email protected]>
AuthorDate: 2018-05-18 14:57:51 +0200
Commit:     Ján Tomko <[email protected]>
CommitDate: 2018-05-23 09:45:48 +0200

qemu: only pass -sandbox off if supported

This way we don't rely on QEMU supplying the -sandbox option without CONFIG_SECCOMP.

git describe: v4.3.0-258-gb87222a909
https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=b87222a90919040c12fb6d7c8dcc20f944a66495

Jano

#12 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 34 lines · Ján Tomko
Quoted 15 lines · Yi Min Zhao
Quoted 12 lines · Ján Tomko
Quoted 10 lines · Eduardo Otubo
Quoted 4 lines · Ján Tomko

But now libvirt requires QEMU >= 1.5.0 which already supports query-command-line-options, so if you want the option gone completely --without-seccomp, I can add the code that probes for it and make seccomp_sandbox = 0 a no-op if it's compiled out.

This looks like a good solution for the libvirt side. Can you add this support
so we can merge this fix?

Quoted 5 lines
Quoted 4 lines

Patches proposed:
https://www.redhat.com/archives/libvir-list/2018-May/msg01430.html

Jano

Thanks for your work!

Now pushed in libvirt master:
commit b87222a90919040c12fb6d7c8dcc20f944a66495 Author:     Ján Tomko <[email protected]>
AuthorDate: 2018-05-18 14:57:51 +0200 Commit:     Ján Tomko <[email protected]>
CommitDate: 2018-05-23 09:45:48 +0200

   qemu: only pass -sandbox off if supported

   This way we don't rely on QEMU supplying the -sandbox option without CONFIG_SECCOMP.

Quoted 8 lines

git describe: v4.3.0-258-gb87222a909
https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=b87222a90919040c12fb6d7c8dcc20f944a66495

Jano

Thanks! But I have not got response from Paolo.  I have added him to CC list.

#13 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 40 lines · Yi Min Zhao
Quoted 37 lines · Ján Tomko
Quoted 15 lines · Yi Min Zhao
Quoted 12 lines · Ján Tomko
Quoted 10 lines · Eduardo Otubo
Quoted 4 lines · Ján Tomko

But now libvirt requires QEMU >= 1.5.0 which already supports query-command-line-options, so if you want the option gone completely --without-seccomp, I can add the code that probes for it and make seccomp_sandbox = 0 a no-op if it's compiled out.

This looks like a good solution for the libvirt side. Can you add this support
so we can merge this fix?

Quoted 5 lines
Quoted 4 lines

Patches proposed:
https://www.redhat.com/archives/libvir-list/2018-May/msg01430.html

Jano

Thanks for your work!

Now pushed in libvirt master:
commit b87222a90919040c12fb6d7c8dcc20f944a66495 Author:     Ján Tomko <[email protected]>
AuthorDate: 2018-05-18 14:57:51 +0200 Commit:     Ján Tomko <[email protected]>
CommitDate: 2018-05-23 09:45:48 +0200

   qemu: only pass -sandbox off if supported

   This way we don't rely on QEMU supplying the -sandbox option without CONFIG_SECCOMP.

Quoted 7 lines
Quoted 5 lines

git describe: v4.3.0-258-gb87222a909
https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=b87222a90919040c12fb6d7c8dcc20f944a66495

Jano

Thanks! But I have not got response from Paolo.  I have added him to CC list.

I'll just wait one more ACK and will send a pull request on the
seccomp queue. Thanks for the contribution.

#14 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 41 lines · Eduardo Otubo
Quoted 40 lines · Yi Min Zhao
Quoted 37 lines · Ján Tomko
Quoted 15 lines · Yi Min Zhao
Quoted 12 lines · Ján Tomko
Quoted 10 lines · Eduardo Otubo
Quoted 4 lines · Ján Tomko

But now libvirt requires QEMU >= 1.5.0 which already supports query-command-line-options, so if you want the option gone completely --without-seccomp, I can add the code that probes for it and make seccomp_sandbox = 0 a no-op if it's compiled out.

This looks like a good solution for the libvirt side. Can you add this support
so we can merge this fix?

Quoted 5 lines
Quoted 4 lines

Patches proposed:
https://www.redhat.com/archives/libvir-list/2018-May/msg01430.html

Jano

Thanks for your work!

Now pushed in libvirt master:
commit b87222a90919040c12fb6d7c8dcc20f944a66495 Author:     Ján Tomko <[email protected]>
AuthorDate: 2018-05-18 14:57:51 +0200 Commit:     Ján Tomko <[email protected]>
CommitDate: 2018-05-23 09:45:48 +0200

   qemu: only pass -sandbox off if supported

   This way we don't rely on QEMU supplying the -sandbox option without CONFIG_SECCOMP.

Quoted 10 lines
Quoted 7 lines
Quoted 5 lines

git describe: v4.3.0-258-gb87222a909
https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=b87222a90919040c12fb6d7c8dcc20f944a66495

Jano

Thanks! But I have not got response from Paolo.  I have added him to CC list.

 I'll just wait one more ACK and will send a pull request on the seccomp queue. Thanks for the contribution.

So... what I should do is wait?

#15 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 48 lines · Yi Min Zhao
Quoted 45 lines · Eduardo Otubo
Quoted 44 lines · Yi Min Zhao
Quoted 41 lines · Ján Tomko
Quoted 15 lines · Yi Min Zhao
Quoted 12 lines · Ján Tomko
Quoted 10 lines · Eduardo Otubo
Quoted 4 lines · Ján Tomko

But now libvirt requires QEMU >= 1.5.0 which already supports query-command-line-options, so if you want the option gone completely --without-seccomp, I can add the code that probes for it and make seccomp_sandbox = 0 a no-op if it's compiled out.

This looks like a good solution for the libvirt side. Can you add this support
so we can merge this fix?

Quoted 5 lines
Quoted 4 lines

Patches proposed:
https://www.redhat.com/archives/libvir-list/2018-May/msg01430.html

Jano

Thanks for your work!

Now pushed in libvirt master:
commit b87222a90919040c12fb6d7c8dcc20f944a66495 Author:     Ján Tomko <[email protected]>
AuthorDate: 2018-05-18 14:57:51 +0200 Commit:     Ján Tomko <[email protected]>
CommitDate: 2018-05-23 09:45:48 +0200

   qemu: only pass -sandbox off if supported

   This way we don't rely on QEMU supplying the -sandbox option without CONFIG_SECCOMP.

git describe: v4.3.0-258-gb87222a909
https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=b87222a90919040c12fb6d7c8dcc20f944a66495

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Jano

Thanks! But I have not got response from Paolo.  I have added him to CC list.

 I'll just wait one more ACK and will send a pull request on the seccomp queue. Thanks for the contribution.

So... what I should do is wait?

Yes, even though I think we're safe to proceed without his explicit ack.

#16 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 11 lines · Eduardo Otubo
Quoted 10 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Thanks! But I have not got response from Paolo.  I have added him to CC list.

 I'll just wait one more ACK and will send a pull request on the seccomp queue. Thanks for the contribution.

So... what I should do is wait?

Yes, even though I think we're safe to proceed without his explicit ack.

The patch is okay; however, as a follow-up, you could consider moving all the CONFIG_SECCOMP code to qemu-seccomp.c.

This way, the only #ifdef remains the one around qemu_opts_foreach.

Paolo

#17 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 10 lines · Paolo Bonzini
Quoted 9 lines · Eduardo Otubo
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

Thanks! But I have not got response from Paolo.  I have added him to CC list.

 I'll just wait one more ACK and will send a pull request on the
seccomp queue. Thanks for the contribution.

So... what I should do is wait?

Quoted 9 lines
Quoted 1 line

Yes, even though I think we're safe to proceed without his explicit ack.

The patch is okay; however, as a follow-up, you could consider moving all the CONFIG_SECCOMP code to qemu-seccomp.c.

This way, the only #ifdef remains the one around qemu_opts_foreach.

Paolo

Thanks for your comment! Indeed, moving to the single C file is much more clear. I will do this after this patch.

@Otubo, what about next step?

#18 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 19 lines · Yi Min Zhao
Quoted 16 lines · Paolo Bonzini
Quoted 10 lines · Eduardo Otubo
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

Thanks! But I have not got response from Paolo.  I have added him to CC list.

  I'll just wait one more ACK and will send a pull request on the seccomp queue. Thanks for the contribution.

So... what I should do is wait?

Yes, even though I think we're safe to proceed without his explicit ack.

The patch is okay; however, as a follow-up, you could consider moving all the CONFIG_SECCOMP code to qemu-seccomp.c.

This way, the only #ifdef remains the one around qemu_opts_foreach.

Quoted 9 lines
Quoted 3 lines

Paolo

Thanks for your comment! Indeed, moving to the single C file is much more clear. I will do this after this patch.

@Otubo, what about next step?

If you're willing to send v3 with the changes Paolo suggested, I can wait to send the pull request. No worries.

#19 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

Quoted 23 lines · Eduardo Otubo
Quoted 22 lines · Yi Min Zhao
Quoted 19 lines · Paolo Bonzini
Quoted 10 lines · Eduardo Otubo
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

Thanks! But I have not got response from Paolo.  I have added him to CC list.

  I'll just wait one more ACK and will send a pull request on the seccomp queue. Thanks for the contribution.

So... what I should do is wait?

Yes, even though I think we're safe to proceed without his explicit ack.

The patch is okay; however, as a follow-up, you could consider moving all the CONFIG_SECCOMP code to qemu-seccomp.c.

This way, the only #ifdef remains the one around qemu_opts_foreach.

Paolo

Quoted 9 lines
Quoted 6 lines

Thanks for your comment! Indeed, moving to the single C file is much more clear. I will do this after this patch.

@Otubo, what about next step?

If you're willing to send v3 with the changes Paolo suggested, I can wait to send the pull request. No worries.

OK. I will update the new version with Paolo's suggestion.

#20 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] sandbox: disable -sandbox if CONFIG_SECCOMP undefined

In reply to Ján Tomko
Quoted 7 lines · Ján Tomko

This patch fixes the usage of QEMU new enough for seccomp blacklist (where libvirt enables the sandbox by default),
but breaks the usage of QEMU with compiled out sandbox and setting
 seccomp_sandbox = 0
in libvirt's qemu.conf:

Quoted 8 lines

error: internal error: process exited while connecting to monitor:
qemu-git: -sandbox off: There is no option group 'sandbox'

But now libvirt requires QEMU >= 1.5.0 which already supports query-command-line-options, so if you want the option gone completely --without-seccomp, I can add the code that probes for it and make seccomp_sandbox = 0 a no-op if it's compiled out.

And that's acceptable - we document that libvirt must be at least as new as qemu. Mixing old qemu + new libvirt should always work, but mixing new qemu + old libvirt may fail, and this is one of those cases. The solution for anyone hitting the failure is to upgrade libvirt to match the fact that they upgraded qemu.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org