qapi: last minute improvements/changes to -compat insecure-types
PATCH 3/8 qapi: rename 'insecure-types' to 'insecure-input'
In reply to Daniel P. BerrangéThis provides better conceptual naming alignment with other -compat flags.
--- docs/system/security.rst | 2 +- qapi/compat.json | 4 ++-- qapi/qapi-util.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
docs/system/security.rst +1 -1
@@ -168,7 +168,7 @@ eligible for CVE assignment. Annotations will be extended to other backend and object types over time, to make their security status explicit. It is possible to control or identify the usage of types that do not offer -an explicit security boundary using the ``insecure-types`` parameter to the +an explicit security boundary using the ``insecure-input`` parameter to the ``-compat`` argument, which accepts three values: * accept: usage of any type will be permitted. This is the current
qapi/compat.json +2 -2
@@ -77,7 +77,7 @@ # @unstable-output: how to handle unstable output (default 'accept') # (since 6.2) # -# @insecure-types: how to handle types that are not declared secure +# @insecure-input: how to handle types that are not declared secure # (default 'accept') (since 11.2) # # Since: 6.0
@@ -87,4 +87,4 @@ '*deprecated-output': 'CompatPolicyOutput', '*unstable-input': 'CompatPolicyInput', '*unstable-output': 'CompatPolicyOutput', - '*insecure-types': 'CompatPolicySecurity' } } + '*insecure-input': 'CompatPolicySecurity' } }
qapi/qapi-util.c +1 -1
@@ -72,7 +72,7 @@ bool compat_policy_check_security(const CompatPolicy *policy,return true; } -switch (policy->insecure_types) { +switch (policy->insecure_input) {case COMPAT_POLICY_SECURITY_ACCEPT :return true;
Signature · 1 line
2.56.0
PATCH 2/8 qapi: add 'warn' option to CompatPolicyInput
In reply to Daniel P. BerrangéThis prints a warning on stderr every time a policy violation is encountered, but accepts the input.
--- qapi/compat.json | 4 +++- qapi/qapi-util.c | 4 ++++ qemu-options.hx | 12 ++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-)
qapi/compat.json +3 -1
@@ -17,10 +17,12 @@ # # @crash: abort() the process # +# @warn: Accept with a warning printed to stderr (Since: 11.2) +# # Since: 6.0 ## { 'enum': 'CompatPolicyInput', - 'data': [ 'accept', 'reject', 'crash' ] } + 'data': [ 'accept', 'reject', 'crash', 'warn' ] } ## # @CompatPolicyOutput:
qapi/qapi-util.c +4 -0
@@ -28,6 +28,10 @@ static bool compat_policy_input_ok1(CompatPolicyInput policy,switch (policy) {case COMPAT_POLICY_INPUT_ACCEPT :return true; +case COMPAT_POLICY_INPUT_WARN : +warn_report ("%s %s %s disabled by policy" , + adjective, kind, name); +return true;case COMPAT_POLICY_INPUT_REJECT :error_set (errp, error_class,"%s %s %s disabled by policy" , adjective, kind, name);
qemu-options.hx +8 -4
@@ -4693,9 +4693,9 @@ DEFHEADING() DEFHEADING(Debug/Expert options:) DEF("compat", HAS_ARG, QEMU_OPTION_compat, - "-compat [deprecated-input=accept|reject|crash][,deprecated-output=accept|hide]\n" + "-compat [deprecated-input=accept|reject|crash|warn][,deprecated-output=accept|hide]\n" " Policy for handling deprecated management interfaces\n" - "-compat [unstable-input=accept|reject|crash][,unstable-output=accept|hide]\n" + "-compat [unstable-input=accept|reject|crash|warn][,unstable-output=accept|hide]\n" " Policy for handling unstable management interfaces\n", QEMU_ARCH_ALL) SRST
@@ -4703,7 +4703,9 @@ SRST Set policy for handling deprecated management interfaces (experimental): ``deprecated-input=accept`` (default) - Accept deprecated commands and arguments + Accept deprecated commands and arguments silently + ``deprecated-input=warn`` + Accept deprecated commands and arguments with warning on stderr ``deprecated-input=reject`` Reject deprecated commands and arguments ``deprecated-input=crash``
@@ -4719,7 +4721,9 @@ SRST Set policy for handling unstable management interfaces (experimental): ``unstable-input=accept`` (default) - Accept unstable commands and arguments + Accept unstable commands and arguments silently + ``unstable-input=warn`` + Accept unstable commands and arguments with warning on stderr ``unstable-input=reject`` Reject unstable commands and arguments ``unstable-input=crash``
Signature · 1 line
2.56.0
PATCH 7/8 qemu-options: document -compat insecure-input parameter
In reply to Daniel P. BerrangéThis adds documentation for the previously added 'insecure-input' parameter to -compat, which controls policy for insecure configuration requests.
--- qemu-options.hx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
qemu-options.hx +21 -1
@@ -4696,7 +4696,9 @@ DEF("compat", HAS_ARG, QEMU_OPTION_compat, "-compat [deprecated-input=accept|reject|crash|warn][,deprecated-output=accept|hide]\n" " Policy for handling deprecated management interfaces\n" "-compat [unstable-input=accept|reject|crash|warn][,unstable-output=accept|hide]\n" - " Policy for handling unstable management interfaces\n", + " Policy for handling unstable management interfaces\n" + "-compat [insecure-input=accept|reject|crash|warn]\n" + " Policy for handling requests for insecure configuration requests\n", QEMU_ARCH_ALL) SRST ``-compat [deprecated-input=<input-policy>][,deprecated-output=<output-policy>]``
@@ -4734,6 +4736,24 @@ SRST Suppress unstable command results and events Limitation: covers only syntactic aspects of QMP. + +``-compat [insecure-input=<input-policy>] + Set policy for handling requests for insecure configuration + requests: + + ``insecure-input=accept`` (default) + Accept insecure configurations requests silently + ``insecure-input=warn`` + Accept insecure configuration requests with warning on stderr + ``insecure-input=reject`` + Reject insecure configuration requests + ``insecure-input=crash`` + Crash on insecure configuration requests + + Limitation: an insecure configuration is one where QEMU has + not intended to provide a security boundary to protect against + malicious usage. Covers only QOM types for devices, machine types + and accelerators. ERST DEF("fw_cfg", HAS_ARG, QEMU_OPTION_fwcfg,
Signature · 1 line
2.56.0
cover qapi: last minute improvements/changes to -compat insecure-types
This addresses various points raised by Markus about the current impl/design, that would need to be addressed before this is included in the release.
NB, the 'warn' option will repeatedly warn on every violation which can be somewhat unpleasant. Figuring out a mechanism to make it a one-time warning is an exercise for the future, given limited time before release.
Daniel P. Berrangé (8):
qapi: make 'CompatPolicy' the first arg in compat_policy_input_ok
qapi: add 'warn' option to CompatPolicyInput
qapi: rename 'insecure-types' to 'insecure-input'
qapi: drop CompatPolicySecurity and use CompatPolicyInput
qapi: rename compat_policy_check_security method
qapi: reverse arg order in compat_policy_security_ok
qemu-options: document -compat insecure-input parameter
qapi: print a message before aborting for -compat violations
docs/system/security.rst | 2 +- include/qapi/compat-policy.h | 12 ++++----- qapi/compat.json | 24 ++++------------- qapi/qapi-util.c | 52 ++++++++++++++++-------------------- qapi/qapi-visit-core.c | 4 +-- qapi/qmp-dispatch.c | 2 +- qapi/qobject-input-visitor.c | 2 +- qemu-options.hx | 34 +++++++++++++++++++---- qom/object.c | 8 +++--- 9 files changed, 72 insertions(+), 68 deletions(-)
Signature · 1 line
2.56.0
PATCH 1/8 qapi: make 'CompatPolicy' the first arg in compat_policy_input_ok
The typical API design pattern is for a method to be named after the type of the first arg passed into the method. For the compat_policy_input_ok method, this points towards 'CompatPolicy' being the first arg, matching compat_policy_check_security.
--- include/qapi/compat-policy.h | 4 ++-- qapi/qapi-util.c | 16 ++++++++-------- qapi/qapi-visit-core.c | 4 ++-- qapi/qmp-dispatch.c | 2 +- qapi/qobject-input-visitor.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-)
include/qapi/compat-policy.h +2 -2
@@ -18,8 +18,8 @@extern CompatPolicy compat_policy; -bool compat_policy_input_ok (uint64_t features, -const CompatPolicy *policy, +bool compat_policy_input_ok (const CompatPolicy *policy, +uint64_t features,ErrorClass error_class,const char *kind,const char *name,Error **errp);
qapi/qapi-util.c +8 -8
@@ -19,8 +19,8 @@CompatPolicy compat_policy; -static bool compat_policy_input_ok1 (const char *adjective, -CompatPolicyInput policy, +static bool compat_policy_input_ok1 (CompatPolicyInput policy, +const char *adjective,ErrorClass error_class,const char *kind,const char *name,Error **errp)
@@ -38,21 +38,21 @@ static bool compat_policy_input_ok1(const char *adjective, } } -bool compat_policy_input_ok (uint64_t features, -const CompatPolicy *policy, +bool compat_policy_input_ok (const CompatPolicy *policy, +uint64_t features,ErrorClass error_class,const char *kind,const char *name,Error **errp) {if ((features &1u <<QAPI_DEPRECATED ) - && !compat_policy_input_ok1 ("Deprecated" , - policy->deprecated_input, + && !compat_policy_input_ok1 (policy->deprecated_input, +"Deprecated" , error_class, kind, name, errp)) {return false; }if ((features & (1u <<QAPI_UNSTABLE )) - && !compat_policy_input_ok1 ("Unstable" , - policy->unstable_input, + && !compat_policy_input_ok1 (policy->unstable_input, +"Unstable" , error_class, kind, name, errp)) {return false; }
qapi/qapi-visit-core.c +2 -2
@@ -410,8 +410,8 @@ static bool input_type_enum(Visitor *v, const char *name, int *obj, }if (lookup->features - && !compat_policy_input_ok (lookup->features[value], - &v->compat_policy, + && !compat_policy_input_ok (&v->compat_policy, + lookup->features[value],ERROR_CLASS_GENERIC_ERROR ,"value" , enum_str, errp)) {return false;
qapi/qmp-dispatch.c +1 -1
@@ -185,7 +185,7 @@ QDict *coroutine_mixed_fn qmp_dispatch(const QmpCommandList *cmds, QObject *requ "The command %s has not been found", command); goto out; } -if (!compat_policy_input_ok (cmd->features, &compat_policy, +if (!compat_policy_input_ok (&compat_policy, cmd->features,ERROR_CLASS_COMMAND_NOT_FOUND ,"command" , command, &err)) { goto out;
qapi/qobject-input-visitor.c +1 -1
@@ -667,7 +667,7 @@ static bool qobject_input_policy_reject(Visitor *v, const char *name,uint64_t features, Error **errp) { - return !compat_policy_input_ok(features, &v->compat_policy, + return !compat_policy_input_ok(&v->compat_policy, features,ERROR_CLASS_GENERIC_ERROR , "parameter", name, errp); }
Signature · 1 line
2.56.0
PATCH 8/8 qapi: print a message before aborting for -compat violations
In reply to Daniel P. BerrangéWhen using the 'crash' policy with -compat options, QEMU will abort() on a policy violation. All the user sees is a core dump though and while the stack trace will ultimately show what the violation was, it can be hard to reverse engineer the cause when variables are optimized out. If the crash is within a CI system, it can be even harder to determine what the cause was as a core dump may not be available.
Printing a message when crashing is easier to diagnose when limited context is available.
--- qapi/qapi-util.c | 3 +++ 1 file changed, 3 insertions(+)
qapi/qapi-util.c +3 -0
@@ -37,6 +37,9 @@ static bool compat_policy_input_ok1(CompatPolicyInput policy, adjective, kind, name);return false;case COMPAT_POLICY_INPUT_CRASH : +error_report ("%s %s %s disabled by policy, aborting" , + adjective, kind, name); +/* fallthrough */ default :abort (); }
Signature · 1 line
2.56.0
PATCH 4/8 qapi: drop CompatPolicySecurity and use CompatPolicyInput
In reply to Daniel P. BerrangéWith CompatPolicyInput gaining a "warn" option, the CompatPolicySecurity type is redundant.
Note the error message for insecure-input changes from
Type 'rtl8139' does not provide a security boundary to protect against untrusted data or actions
To
Insecure QOM type rtl8139 disabled by policy
--- qapi/compat.json | 18 +----------------- qapi/qapi-util.c | 21 ++++----------------- 2 files changed, 5 insertions(+), 34 deletions(-)
qapi/compat.json +1 -17
@@ -37,22 +37,6 @@ { 'enum': 'CompatPolicyOutput', 'data': [ 'accept', 'hide' ] } -## -# @CompatPolicySecurity: -# Policy for handling any devices or backends which do not provide -# a security boundary to protect against untrusted environments -# -# @accept: Allow any usage -# -# @reject: Reject with an error reported -# -# @warn: Allow any usage, with a warning reported -# -# Since: 11.2 -## -{ 'enum': 'CompatPolicySecurity', - 'data': [ 'accept', 'reject', 'warn' ] } - ## # @CompatPolicy: # Policy for handling deprecated management interfaces.
@@ -87,4 +71,4 @@ '*deprecated-output': 'CompatPolicyOutput', '*unstable-input': 'CompatPolicyInput', '*unstable-output': 'CompatPolicyOutput', - '*insecure-input': 'CompatPolicySecurity' } } + '*insecure-input': 'CompatPolicyInput' } }
qapi/qapi-util.c +4 -17
@@ -72,23 +72,10 @@ bool compat_policy_check_security(const CompatPolicy *policy,return true; } -switch (policy->insecure_input) { -case COMPAT_POLICY_SECURITY_ACCEPT : -return true; - -case COMPAT_POLICY_SECURITY_REJECT : -error_setg (errp,"Type '%s' does not provide a security boundary " -"to protect against untrusted data or actions" , typename); -return false; - -case COMPAT_POLICY_SECURITY_WARN : -warn_report ("Type '%s' does not provide a security boundary " -"to protect against untrusted data or actions" , typename); -return true; - -default : -g_assert_not_reached (); - } +return compat_policy_input_ok1 (policy->insecure_input, +"Insecure" , +ERROR_CLASS_GENERIC_ERROR , +"QOM type" , typename, errp); }
Signature · 1 line
2.56.0
PATCH 5/8 qapi: rename compat_policy_check_security method
In reply to Daniel P. BerrangéRename to compat_policy_security_ok to match the naming convention established by compat_policy_input_ok.
--- include/qapi/compat-policy.h | 8 ++++---- qapi/qapi-util.c | 8 ++++---- qom/object.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-)
include/qapi/compat-policy.h +4 -4
@@ -24,10 +24,10 @@ bool compat_policy_input_ok(const CompatPolicy *policy, const char *kind, const char *name, Error **errp); -bool compat_policy_check_security (const CompatPolicy *policy, -const char *typename, -bool is_secure, -Error **errp); +bool compat_policy_security_ok (const CompatPolicy *policy, +const char *typename, +bool is_secure, +Error **errp);/* * Create a QObject input visitor for @obj for use with QMP
qapi/qapi-util.c +4 -4
@@ -63,10 +63,10 @@ bool compat_policy_input_ok(const CompatPolicy *policy,return true; } -bool compat_policy_check_security (const CompatPolicy *policy, -const char *typename, -bool is_secure, -Error **errp) +bool compat_policy_security_ok (const CompatPolicy *policy, +const char *typename, +bool is_secure, +Error **errp) {if (is_secure) {return true;
qom/object.c +4 -4
@@ -3276,10 +3276,10 @@ void object_class_property_set_description(ObjectClass *klass,bool object_class_check_security (ObjectClass *klass,Error **errp) { -return compat_policy_check_security (&compat_policy, -object_class_get_name (klass), -object_class_is_secure (klass), - errp); +return compat_policy_security_ok (&compat_policy, +object_class_get_name (klass), +object_class_is_secure (klass), + errp); }static void object_class_init (ObjectClass *klass,const void *data)
Signature · 1 line
2.56.0
PATCH 6/8 qapi: reverse arg order in compat_policy_security_ok
In reply to Daniel P. BerrangéMatch the compat_policy_input_ok design more closely by having the "relevant facts" being checked as the 2nd argument.
--- include/qapi/compat-policy.h | 2 +- qapi/qapi-util.c | 2 +- qom/object.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
include/qapi/compat-policy.h +1 -1
@@ -25,8 +25,8 @@ bool compat_policy_input_ok(const CompatPolicy *policy, Error **errp);bool compat_policy_security_ok (const CompatPolicy *policy, -const char *typename,bool is_secure, +const char *typename,Error **errp);/*
qapi/qapi-util.c +1 -1
@@ -64,8 +64,8 @@ bool compat_policy_input_ok(const CompatPolicy *policy, }bool compat_policy_security_ok (const CompatPolicy *policy, -const char *typename,bool is_secure, +const char *typename,Error **errp) {if (is_secure) {
qom/object.c +1 -1
@@ -3277,8 +3277,8 @@ void object_class_property_set_description(ObjectClass *klass,bool object_class_check_security (ObjectClass *klass,Error **errp) {return compat_policy_security_ok (&compat_policy, -object_class_get_name (klass),object_class_is_secure (klass), +object_class_get_name (klass), errp); }
Signature · 1 line
2.56.0
Re: [PATCH 4/8] qapi: drop CompatPolicySecurity and use CompatPolicyInput
In reply to Daniel P. BerrangéQuoted 11 lines · Daniel P. Berrangé
With CompatPolicyInput gaining a "warn" option, the CompatPolicySecurity type is redundant.
Note the error message for insecure-input changes from
Type 'rtl8139' does not provide a security boundary to protect against untrusted data or actions
To
Insecure QOM type rtl8139 disabled by policy
This loses a bit of information. Do we care? I show a way to retain it below.
Quoted 35 lines
Signed-off-by Daniel P. Berrangé <[email protected]>--- qapi/compat.json | 18 +----------------- qapi/qapi-util.c | 21 ++++----------------- 2 files changed, 5 insertions(+), 34 deletions(-)qapi/compat.json +0
-16@@ -37,22 +37,6 @@ { 'enum': 'CompatPolicyOutput', 'data': [ 'accept', 'hide' ] } -## -# @CompatPolicySecurity: -# Policy for handling any devices or backends which do not provide -# a security boundary to protect against untrusted environments -# -# @accept: Allow any usage -# -# @reject: Reject with an error reported -# -# @warn: Allow any usage, with a warning reported -# -# Since: 11.2 -## -{ 'enum': 'CompatPolicySecurity', - 'data': [ 'accept', 'reject', 'warn' ] } - ## # @CompatPolicy: # Policy for handling deprecated management interfaces.
qapi/compat.json line 74
Quoted 5 lines
qapi/compat.json +1
-1@@ -87,4 +71,4 @@ '*deprecated-output': 'CompatPolicyOutput', '*unstable-input': 'CompatPolicyInput', '*unstable-output': 'CompatPolicyOutput', - '*insecure-input': 'CompatPolicySecurity' } } + '*insecure-input': 'CompatPolicyInput' } }
This adds policy value "crash", doesn't it? The commit message should mention it.
Quoted 20 lines
qapi/qapi-util.c +0
-12@@ -72,23 +72,10 @@ bool compat_policy_check_security(const CompatPolicy *policy,return true; } -switch (policy->insecure_input) { -case COMPAT_POLICY_SECURITY_ACCEPT : -return true; - -case COMPAT_POLICY_SECURITY_REJECT : -error_setg (errp,"Type '%s' does not provide a security boundary " -"to protect against untrusted data or actions" , typename); -return false; - -case COMPAT_POLICY_SECURITY_WARN : -warn_report ("Type '%s' does not provide a security boundary " -"to protect against untrusted data or actions" , typename);
qapi/qapi-util.c bool compat_policy_check_security(const CompatPolicy *policy, · line 79
Quoted 10 lines
qapi/qapi-util.c +4
-5-return true; - -default : -g_assert_not_reached (); - } +return compat_policy_input_ok1 (policy->insecure_input, +"Insecure" , +ERROR_CLASS_GENERIC_ERROR , +"QOM type" , typename, errp); }
... then try something like this:
if (!compat_policy_input_ok1(...) {
error_append_hint(errp, ...);
}Don't forget ERRP_GUARD() then, error_append_hint() needs it.
Re: [PATCH 7/8] qemu-options: document -compat insecure-input parameter
In reply to Daniel P. BerrangéQuoted 34 lines · Daniel P. Berrangé
This adds documentation for the previously added 'insecure-input' parameter to -compat, which controls policy for insecure configuration requests.
Signed-off-by Daniel P. Berrangé <[email protected]>--- qemu-options.hx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)qemu-options.hx +9
-1@@ -4696,7 +4696,9 @@ DEF("compat", HAS_ARG, QEMU_OPTION_compat, "-compat [deprecated-input=accept|reject|crash|warn][,deprecated-output=accept|hide]\n" " Policy for handling deprecated management interfaces\n" "-compat [unstable-input=accept|reject|crash|warn][,unstable-output=accept|hide]\n" - " Policy for handling unstable management interfaces\n", + " Policy for handling unstable management interfaces\n" + "-compat [insecure-input=accept|reject|crash|warn]\n" + " Policy for handling requests for insecure configuration requests\n", QEMU_ARCH_ALL) SRST ``-compat [deprecated-input=<input-policy>][,deprecated-output=<output-policy>]``@@ -4734,6 +4736,24 @@ SRST Suppress unstable command results and events Limitation: covers only syntactic aspects of QMP. + +``-compat [insecure-input=<input-policy>] + Set policy for handling requests for insecure configuration + requests: + + ``insecure-input=accept`` (default)
qemu-options.hx SRST · line 4754
Quoted 10 lines
qemu-options.hx +10
-0+ Accept insecure configurations requests silently + ``insecure-input=warn`` + Accept insecure configuration requests with warning on stderr + ``insecure-input=reject`` + Reject insecure configuration requests + ``insecure-input=crash`` + Crash on insecure configuration requests + + Limitation: an insecure configuration is one where QEMU has + not intended to provide a security boundary to protect against
"Where QEMU has not intended to provide" sounds odd to me. Mind, I'm not a native speaker. "Where QEMU does not provide".
qemu-options.hx SRST · line 4756
Quoted 2 lines
qemu-options.hx +2
-0+ malicious usage. Covers only QOM types for devices, machine types + and accelerators.
The policy check is in
* qemu_create_machine(), which covers machine creation.
* do_configure_accelerator(), which covers accelerator creation.
* qdev_device_add_from_qdict(), which covers *some* device creation:
* device_add and -device always
* Half of -audio model=hda: covers the "intel-hda" device, but not the "hda-duplex" device. See intel_hda_and_codec_init().
* The "primary device" created in failover_hide_primary_device() for the virtio-net standby feature.
* The "usb-host" device device created in xen-usb.c for some reason.
There's plenty of device creation it doesn't cover. Isn't this problematic? I certainly expected it to cover *all* device creation!
Say board code creates a certain onboard device with the usual low level interfaces like qdev_new() and qdev_realize(). Say we mark the onboard device insecure. The policy check doesn't apply. We need to manually mark the machine type insecure as well. Feels awfully prone to human error.
Moreover, what if the onboard device is configurable? Then the machine type may be secure unless you configure this insecure device. Marking the machine type would be too coarse.
Could we check policy in qdev_realize() instead?
Quoted 3 lines
qemu-options.hx +0
-0ERST DEF("fw_cfg", HAS_ARG, QEMU_OPTION_fwcfg,
Re: [PATCH 2/8] qapi: add 'warn' option to CompatPolicyInput
In reply to Daniel P. BerrangéQuoted 4 lines · Daniel P. Berrangé
This prints a warning on stderr every time a policy violation is encountered, but accepts the input.
Signed-off-by Daniel P. Berrangé <[email protected]>
"Every time" can be annoying. It's commonly easy to avoid, e.g. with warn_report_once(), but not here, so we don't. Because it's annoying, we don't make it the default, unlike other deprecation warnings.
If you agree with the above, please work it into the commit message, and consider whether documentation should mention it, too.
Re: [PATCH 2/8] qapi: add 'warn' option to CompatPolicyInput
Quoted 5 lines · Markus Armbruster
Quoted 3 lines · Daniel P. Berrangé
This prints a warning on stderr every time a policy violation is encountered, but accepts the input.
Quoted 8 lines
Quoted 1 line
Signed-off-by Daniel P. Berrangé <[email protected]>"Every time" can be annoying. It's commonly easy to avoid, e.g. with
warn_report_once(), but not here, so we don't. Because it's annoying, we don't make it the default, unlike other deprecation warnings.If you agree with the above, please work it into the commit message, and consider whether documentation should mention it, too.
Ok.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH 4/8] qapi: drop CompatPolicySecurity and use CompatPolicyInput
In reply to Markus ArmbrusterQuoted 52 lines · Markus Armbruster
Quoted 11 lines · Daniel P. Berrangé
With CompatPolicyInput gaining a "warn" option, the CompatPolicySecurity type is redundant.
Note the error message for insecure-input changes from
Type 'rtl8139' does not provide a security boundary to protect against untrusted data or actions
To
Insecure QOM type rtl8139 disabled by policy
This loses a bit of information. Do we care? I show a way to retain it below.
Quoted 35 lines
Signed-off-by Daniel P. Berrangé <[email protected]>--- qapi/compat.json | 18 +----------------- qapi/qapi-util.c | 21 ++++----------------- 2 files changed, 5 insertions(+), 34 deletions(-)qapi/compat.json +0
-16@@ -37,22 +37,6 @@ { 'enum': 'CompatPolicyOutput', 'data': [ 'accept', 'hide' ] } -## -# @CompatPolicySecurity: -# Policy for handling any devices or backends which do not provide -# a security boundary to protect against untrusted environments -# -# @accept: Allow any usage -# -# @reject: Reject with an error reported -# -# @warn: Allow any usage, with a warning reported -# -# Since: 11.2 -## -{ 'enum': 'CompatPolicySecurity', - 'data': [ 'accept', 'reject', 'warn' ] } - ## # @CompatPolicy: # Policy for handling deprecated management interfaces.@@ -87,4 +71,4 @@
Quoted 8 lines
qapi/compat.json line 74
Quoted 5 lines
qapi/compat.json +1
-1'*deprecated-output': 'CompatPolicyOutput', '*unstable-input': 'CompatPolicyInput', '*unstable-output': 'CompatPolicyOutput', - '*insecure-input': 'CompatPolicySecurity' } } + '*insecure-input': 'CompatPolicyInput' } }This adds policy value "crash", doesn't it? The commit message should mention it.
Ok
Quoted 34 lines
Quoted 21 lines
qapi/qapi-util.c +0
-12@@ -72,23 +72,10 @@ bool compat_policy_check_security(const CompatPolicy *policy,return true; } -switch (policy->insecure_input) { -case COMPAT_POLICY_SECURITY_ACCEPT : -return true; - -case COMPAT_POLICY_SECURITY_REJECT : -error_setg (errp,"Type '%s' does not provide a security boundary " -"to protect against untrusted data or actions" , typename); -return false; - -case COMPAT_POLICY_SECURITY_WARN : -warn_report ("Type '%s' does not provide a security boundary " -"to protect against untrusted data or actions" , typename);qapi/qapi-util.c bool compat_policy_check_security(const CompatPolicy *policy, · line 79
Quoted 10 lines
qapi/qapi-util.c +4
-5-return true; - -default : -g_assert_not_reached (); - } +return compat_policy_input_ok1 (policy->insecure_input, +"Insecure" , +ERROR_CLASS_GENERIC_ERROR , +"QOM type" , typename, errp); }... then try something like this:
Quoted 5 lines
if (!compat_policy_input_ok1(...) { error_append_hint(errp, ...); }Don't forget
ERRP_GUARD()then,error_append_hint()needs it.
Yep, that's a nice idea.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH 7/8] qemu-options: document -compat insecure-input parameter
In reply to Markus ArmbrusterQuoted 41 lines · Markus Armbruster
Quoted 39 lines · Daniel P. Berrangé
This adds documentation for the previously added 'insecure-input' parameter to -compat, which controls policy for insecure configuration requests.
Signed-off-by Daniel P. Berrangé <[email protected]>--- qemu-options.hx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)qemu-options.hx +14
-1@@ -4696,7 +4696,9 @@ DEF("compat", HAS_ARG, QEMU_OPTION_compat, "-compat [deprecated-input=accept|reject|crash|warn][,deprecated-output=accept|hide]\n" " Policy for handling deprecated management interfaces\n" "-compat [unstable-input=accept|reject|crash|warn][,unstable-output=accept|hide]\n" - " Policy for handling unstable management interfaces\n", + " Policy for handling unstable management interfaces\n" + "-compat [insecure-input=accept|reject|crash|warn]\n" + " Policy for handling requests for insecure configuration requests\n", QEMU_ARCH_ALL) SRST ``-compat [deprecated-input=<input-policy>][,deprecated-output=<output-policy>]``@@ -4734,6 +4736,24 @@ SRST Suppress unstable command results and events Limitation: covers only syntactic aspects of QMP. + +``-compat [insecure-input=<input-policy>] + Set policy for handling requests for insecure configuration + requests: + + ``insecure-input=accept`` (default) + Accept insecure configurations requests silently + ``insecure-input=warn`` + Accept insecure configuration requests with warning on stderr + ``insecure-input=reject`` + Reject insecure configuration requests
Quoted 8 lines
qemu-options.hx SRST · line 4754
Quoted 5 lines
qemu-options.hx +5
-0+ ``insecure-input=crash`` + Crash on insecure configuration requests + + Limitation: an insecure configuration is one where QEMU has + not intended to provide a security boundary to protect against"Where QEMU has not intended to provide" sounds odd to me. Mind, I'm not a native speaker. "Where QEMU does not provide".
Yeah, that language choice was me by pessimistic expecting that QEMU is full of undiscovered flaws. I'll change to what you suggested.
Quoted 16 lines
qemu-options.hx SRST · line 4756
Quoted 2 lines
qemu-options.hx +2
-0+ malicious usage. Covers only QOM types for devices, machine types + and accelerators.The policy check is in
*
qemu_create_machine(), which covers machine creation.*
do_configure_accelerator(), which covers accelerator creation.*
qdev_device_add_from_qdict(), which covers *some* device creation:*
device_addand -device always* Half of -audio model=hda: covers the "intel-hda" device, but not the "hda-duplex" device. See
intel_hda_and_codec_init().
Quoted 7 lines
* The "primary device" created in
failover_hide_primary_device()for the virtio-net standby feature.* The "usb-host" device device created in
xen-usb.cfor some reason.There's plenty of device creation it doesn't cover. Isn't this problematic? I certainly expected it to cover *all* device creation!
Yes, eventually, but not yet....
Quoted 7 lines
Say board code creates a certain onboard device with the usual low level interfaces like
qdev_new()andqdev_realize(). Say we mark the onboard device insecure. The policy check doesn't apply. We need to manually mark the machine type insecure as well. Feels awfully prone to human error.
Quoted 5 lines
Moreover, what if the onboard device is configurable? Then the machine type may be secure unless you configure this insecure device. Marking the machine type would be too coarse.
Could we check policy in
qdev_realize()instead?
Yes and no.
To make this a tractable problem I only wanted to add '.secure = true' annotations for public facing types initially, so needed the check in the device_add/-device code path only.
This is sufficient to let us tell bug report filers to take their demo command line and add
'-compat insecure-input=reject -nodfaults'
as a pre-requisite for a bug being considered a security flaw egligible for CVE handling.
If we put a check in qdev_realize(), then we need to add annotations for *all* types, before the -compat insecure-input=.... option is viable to use. That requires a much bigger effort to mark all types.
In the 12.0 dev cycle, my intention is to
a) Expand ".secure = true" markers to all parents of leaf node types marked secure, and enforce them.
b) Expand ".secure = true" markers to all built-in devices that are indirectly created by a leaf node type marked secure, when -nodefaults is present
Once (b) is done, then qdev_realize() will likely be the better place to put the policy check.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH 7/8] qemu-options: document -compat insecure-input parameter
Quoted 115 lines · Daniel P. Berrangé
Quoted 41 lines · Markus Armbruster
Quoted 39 lines · Daniel P. Berrangé
This adds documentation for the previously added 'insecure-input' parameter to -compat, which controls policy for insecure configuration requests.
Signed-off-by Daniel P. Berrangé <[email protected]>--- qemu-options.hx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)qemu-options.hx +14
-1@@ -4696,7 +4696,9 @@ DEF("compat", HAS_ARG, QEMU_OPTION_compat, "-compat [deprecated-input=accept|reject|crash|warn][,deprecated-output=accept|hide]\n" " Policy for handling deprecated management interfaces\n" "-compat [unstable-input=accept|reject|crash|warn][,unstable-output=accept|hide]\n" - " Policy for handling unstable management interfaces\n", + " Policy for handling unstable management interfaces\n" + "-compat [insecure-input=accept|reject|crash|warn]\n" + " Policy for handling requests for insecure configuration requests\n", QEMU_ARCH_ALL) SRST ``-compat [deprecated-input=<input-policy>][,deprecated-output=<output-policy>]``@@ -4734,6 +4736,24 @@ SRST Suppress unstable command results and events Limitation: covers only syntactic aspects of QMP. + +``-compat [insecure-input=<input-policy>] + Set policy for handling requests for insecure configuration + requests: + + ``insecure-input=accept`` (default) + Accept insecure configurations requests silently + ``insecure-input=warn`` + Accept insecure configuration requests with warning on stderr + ``insecure-input=reject`` + Reject insecure configuration requestsQuoted 8 lines
qemu-options.hx SRST · line 4754
Quoted 5 lines
qemu-options.hx +5
-0+ ``insecure-input=crash`` + Crash on insecure configuration requests + + Limitation: an insecure configuration is one where QEMU has + not intended to provide a security boundary to protect against"Where QEMU has not intended to provide" sounds odd to me. Mind, I'm not a native speaker. "Where QEMU does not provide".
Yeah, that language choice was me by pessimistic expecting that QEMU is full of undiscovered flaws. I'll change to what you suggested.
Quoted 16 lines
qemu-options.hx SRST · line 4756
Quoted 2 lines
qemu-options.hx +2
-0+ malicious usage. Covers only QOM types for devices, machine types + and accelerators.The policy check is in
*
qemu_create_machine(), which covers machine creation.*
do_configure_accelerator(), which covers accelerator creation.*
qdev_device_add_from_qdict(), which covers *some* device creation:*
device_addand -device always* Half of -audio model=hda: covers the "intel-hda" device, but not the "hda-duplex" device. See
intel_hda_and_codec_init().Quoted 7 lines
* The "primary device" created in
failover_hide_primary_device()for the virtio-net standby feature.* The "usb-host" device device created in
xen-usb.cfor some reason.There's plenty of device creation it doesn't cover. Isn't this problematic? I certainly expected it to cover *all* device creation!
Yes, eventually, but not yet....
Quoted 7 lines
Say board code creates a certain onboard device with the usual low level interfaces like
qdev_new()andqdev_realize(). Say we mark the onboard device insecure. The policy check doesn't apply. We need to manually mark the machine type insecure as well. Feels awfully prone to human error.Quoted 5 lines
Moreover, what if the onboard device is configurable? Then the machine type may be secure unless you configure this insecure device. Marking the machine type would be too coarse.
Could we check policy in
qdev_realize()instead?Yes and no.
To make this a tractable problem I only wanted to add '.secure = true' annotations for public facing types initially, so needed the check in the device_add/-device code path only.
This is sufficient to let us tell bug report filers to take their demo command line and add
'-compat insecure-input=reject -nodfaults'
as a pre-requisite for a bug being considered a security flaw egligible for CVE handling.
If we put a check in
qdev_realize(), then we need to add annotations for *all* types, before the -compat insecure-input=.... option is viable to use. That requires a much bigger effort to mark all types.In the 12.0 dev cycle, my intention is to
Quoted 8 lines
a) Expand ".secure = true" markers to all parents of leaf node types marked secure, and enforce them.
b) Expand ".secure = true" markers to all built-in devices that are indirectly created by a leaf node type marked secure, when -nodefaults is presentOnce (b) is done, then
qdev_realize()will likely be the better place to put the policy check.
Let's see whether I got this.
* A type can be known to be secure, known to be insecure, or unknown.
* Exactly the types known to be secure are marked secure. Thus, the policy check must treat known to be insecure and unknown the same, which makes sense.
* We start with all types unknown.
* To move a type from unknown to known, we need to examine it. Examining all types in time for the next release is infeasible. Even examining all types usable with a useful set of machines is infeasible. What is feasible is examining a useful set of types available with certain user interfaces, so that's what we did.
* We check the policy in these interfaces only. This lets users restrict these interfaces to known secure types, which is useful.
* However, types created differently get a blanket exception. Not ideal, but no worse than before, unless the new policy creates a false sense of security. The best we can (and should) do about that is to clearly document the policy's current limitations.
Right?
Re: [PATCH 7/8] qemu-options: document -compat insecure-input parameter
Quoted 29 lines · Markus Armbruster
Quoted 18 lines · Daniel P. Berrangé
Quoted 10 lines · Markus Armbruster
Quoted 8 lines · Daniel P. Berrangé
This adds documentation for the previously added 'insecure-input' parameter to -compat, which controls policy for insecure configuration requests.
Signed-off-by Daniel P. Berrangé <[email protected]>--- qemu-options.hx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)If we put a check in
qdev_realize(), then we need to add annotations for *all* types, before the -compat insecure-input=.... option is viable to use. That requires a much bigger effort to mark all types.In the 12.0 dev cycle, my intention is to
Quoted 8 lines
a) Expand ".secure = true" markers to all parents of leaf node types marked secure, and enforce them.
b) Expand ".secure = true" markers to all built-in devices that are indirectly created by a leaf node type marked secure, when -nodefaults is presentOnce (b) is done, then
qdev_realize()will likely be the better place to put the policy check.
Quoted 7 lines
Let's see whether I got this.
* A type can be known to be secure, known to be insecure, or unknown.
* Exactly the types known to be secure are marked secure. Thus, the policy check must treat known to be insecure and unknown the same, which makes sense.
Yes, we're explicitly not distinguishing 'insecure' vs 'unknown' either internally or externally. Something is either explicitly marked as secure, otherwise it is insecure.
Quoted 1 line
* We start with all types unknown.
aka all types are insecure.
Quoted 5 lines
* To move a type from unknown to known, we need to examine it. Examining all types in time for the next release is infeasible. Even examining all types usable with a useful set of machines is infeasible. What is feasible is examining a useful set of types available with certain user interfaces, so that's what we did.
Yes.
Quoted 2 lines
* We check the policy in these interfaces only. This lets users restrict these interfaces to known secure types, which is useful.
Yes.
Quoted 6 lines
* However, types created differently get a blanket exception. Not ideal, but no worse than before, unless the new policy creates a false sense of security. The best we can (and should) do about that is to clearly document the policy's current limitations.
Right?
Yes.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH 2/8] qapi: add 'warn' option to CompatPolicyInput
In reply to Daniel P. BerrangéQuoted 34 lines
This prints a warning on stderr every time a policy violation is encountered, but accepts the input.
Signed-off-by Daniel P. Berrangé <[email protected]>Message-ID: <[email protected]>
--- qapi/compat.json | 4 +++- qapi/qapi-util.c | 4 ++++ qemu-options.hx | 12 ++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-)qapi/compat.json +3
-1@@ -17,10 +17,12 @@ # # @crash: abort() the process # +# @warn: Accept with a warning printed to stderr (Since: 11.2) +# # Since: 6.0 ## { 'enum': 'CompatPolicyInput', - 'data': [ 'accept', 'reject', 'crash' ] } + 'data': [ 'accept', 'reject', 'crash', 'warn' ] } ## # @CompatPolicyOutput:qapi/qapi-util.c +0
-0
qapi/qapi-util.c static bool compat_policy_input_ok1(CompatPolicyInput policy, · line 32
Quoted 5 lines
qapi/qapi-util.c +2
-0@@ -28,6 +28,10 @@ static bool compat_policy_input_ok1(CompatPolicyInput policy,switch (policy) {case COMPAT_POLICY_INPUT_ACCEPT :return true; +case COMPAT_POLICY_INPUT_WARN : + warn_report("%s %s %s disabled by policy",
rather: "Deprecated %s.. accepted by policy"?
Signature · 1 line
Marc-André Lureau <[email protected]>
Re: [PATCH 4/8] qapi: drop CompatPolicySecurity and use CompatPolicyInput
In reply to Daniel P. BerrangéSignature · 1 line
Marc-André Lureau <[email protected]>
Re: [PATCH 8/8] qapi: print a message before aborting for -compat violations
In reply to Daniel P. BerrangéQuoted 22 lines
When using the 'crash' policy with -compat options, QEMU will
abort()on a policy violation. All the user sees is a core dump though and while the stack trace will ultimately show what the violation was, it can be hard to reverse engineer the cause when variables are optimized out. If the crash is within a CI system, it can be even harder to determine what the cause was as a core dump may not be available.Printing a message when crashing is easier to diagnose when limited context is available.
Signed-off-by Daniel P. Berrangé <[email protected]>Message-ID: <[email protected]>
--- qapi/qapi-util.c | 3 +++ 1 file changed, 3 insertions(+)qapi/qapi-util.c +0
-0
qapi/qapi-util.c static bool compat_policy_input_ok1(CompatPolicyInput policy, · line 41
Quoted 5 lines
qapi/qapi-util.c +2
-0@@ -37,6 +37,9 @@ static bool compat_policy_input_ok1(CompatPolicyInput policy, adjective, kind, name);return false;case COMPAT_POLICY_INPUT_CRASH : +error_report ("%s %s %s disabled by policy, aborting" , + adjective, kind, name);
miss-aligned
Signature · 1 line
Marc-André Lureau <[email protected]>
Re: [PATCH 7/8] qemu-options: document -compat insecure-input parameter
In reply to Daniel P. BerrangéQuoted 15 lines
This adds documentation for the previously added 'insecure-input' parameter to -compat, which controls policy for insecure configuration requests.
Signed-off-by Daniel P. Berrangé <[email protected]>Message-ID: <[email protected]>
--- qemu-options.hx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)qemu-options.hx +0
-0
qemu-options.hx DEF("compat", HAS_ARG, QEMU_OPTION_compat, · line 4701
Quoted 7 lines
qemu-options.hx +3
-1@@ -4696,7 +4696,9 @@ DEF("compat", HAS_ARG, QEMU_OPTION_compat, "-compat [deprecated-input=accept|reject|crash|warn][,deprecated-output=accept|hide]\n" " Policy for handling deprecated management interfaces\n" "-compat [unstable-input=accept|reject|crash|warn][,unstable-output=accept|hide]\n" - " Policy for handling unstable management interfaces\n", + " Policy for handling unstable management interfaces\n" + "-compat [insecure-input=accept|reject|crash|warn]\n" + " Policy for handling requests for insecure configuration requests\n",
"Policy for handling insecure configuration requests"?
qemu-options.hx SRST · line 4740
Quoted 9 lines
qemu-options.hx +2
-0QEMU_ARCH_ALL) SRST ``-compat [deprecated-input=<input-policy>][,deprecated-output=<output-policy>]``@@ -4734,6 +4736,24 @@ SRST Suppress unstable command results and events Limitation: covers only syntactic aspects of QMP. + +``-compat [insecure-input=<input-policy>]
Missing closing ``
Quoted 4 lines
qemu-options.hx +4
-0+ Set policy for handling requests for insecure configuration + requests: + + ``insecure-input=accept`` (default)
qemu-options.hx SRST · line 4754
Quoted 10 lines
qemu-options.hx +9
-0+ Accept insecure configurations requests silently + ``insecure-input=warn`` + Accept insecure configuration requests with warning on stderr + ``insecure-input=reject`` + Reject insecure configuration requests + ``insecure-input=crash`` + Crash on insecure configuration requests + + Limitation: an insecure configuration is one where QEMU has
docs/system/security.rst still states that insecure-input "accepts three values" and lists only accept, warn and reject. Add missing 'crash'.
qemu-options.hx SRST · line 4754
Quoted 1 line
qemu-options.hx +1
-0+ not intended to provide a security boundary to protect against
does not intend
Signature · 1 line
Marc-André Lureau <[email protected]>
Re: [PATCH 2/8] qapi: add 'warn' option to CompatPolicyInput
In reply to [email protected]Quoted 27 lines · On Fri, Oct 30, 2026 at 04:49:21PM +0400, [email protected] wrote:
Quoted 27 lines
This prints a warning on stderr every time a policy violation is encountered, but accepts the input.
Signed-off-by Daniel P. Berrangé <[email protected]>Message-ID: <[email protected]>
--- qapi/compat.json | 4 +++- qapi/qapi-util.c | 4 ++++ qemu-options.hx | 12 ++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-)qapi/compat.json +3
-1@@ -17,10 +17,12 @@ # # @crash: abort() the process # +# @warn: Accept with a warning printed to stderr (Since: 11.2) +# # Since: 6.0 ## { 'enum': 'CompatPolicyInput', - 'data': [ 'accept', 'reject', 'crash' ] } + 'data': [ 'accept', 'reject', 'crash', 'warn' ] }
Quoted 14 lines
qapi/qapi-util.c static bool compat_policy_input_ok1(CompatPolicyInput policy, · line 32
Quoted 12 lines
qapi/compat.json +0
-0## # @CompatPolicyOutput:qapi/qapi-util.c +2
-0@@ -28,6 +28,10 @@ static bool compat_policy_input_ok1(CompatPolicyInput policy,switch (policy) {case COMPAT_POLICY_INPUT_ACCEPT :return true; +case COMPAT_POLICY_INPUT_WARN : + warn_report("%s %s %s disabled by policy",rather: "Deprecated %s.. accepted by policy"?
Yes, it should say 'accepted'.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|