All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: Gerd Hoffmann <kraxel@redhat.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: Re: [PATCH v2 2/2] hw/uefi: disable debug function
Date: Thu, 2 Jul 2026 14:56:51 +0200	[thread overview]
Message-ID: <2a13fcae-779a-4596-bd2d-c5cd7cf8ad1f@oss.qualcomm.com> (raw)
In-Reply-To: <20260702092349.4183512-3-kraxel@redhat.com>

Hi Gerd,

On 2/7/26 11:23, Gerd Hoffmann wrote:
> This was never meant to be active in production builds.  It's a code
> path not hit on a normal boot (OVMF wouldn't try variable updates which
> are not allowed), so this went unnoticed.
> 
> Wrap the call into "if (VARIABLE_POLICY_DEBUG)" so it is never used
> unless the #define is changed to true.
> 
> Also fix the name printing to not overrun the entry size.
> 
> Fixes: CVE-2026-58582
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3615
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   hw/uefi/var-service-policy.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/uefi/var-service-policy.c b/hw/uefi/var-service-policy.c
> index 989bf87ddb86..b56fc62f7092 100644
> --- a/hw/uefi/var-service-policy.c
> +++ b/hw/uefi/var-service-policy.c
> @@ -16,6 +16,8 @@
>   
>   #include "trace.h"
>   
> +#define VARIABLE_POLICY_DEBUG 0

To avoid this anti-pattern, ...

>   static void calc_policy(uefi_var_policy *pol);
>   
>   static int uefi_var_policy_post_load(void *opaque, int version_id)
> @@ -40,11 +42,12 @@ const VMStateDescription vmstate_uefi_var_policy = {
>   static void print_policy_entry(variable_policy_entry *pe)
>   {
>       uint16_t *name = (void *)pe + pe->offset_to_name;
> +    uint16_t *end = (void *)pe + pe->size;
>   
>       fprintf(stderr, "%s:\n", __func__);
>   
>       fprintf(stderr, "    name ´");
> -    while (*name) {
> +    while (*name && name < end) {
>           fprintf(stderr, "%c", *name);
>           name++;
>       }
> @@ -173,7 +176,9 @@ efi_status uefi_vars_policy_check(uefi_vars_state *uv,
>       pe = pol->entry;
>   
>       uefi_trace_variable(__func__, var->guid, var->name, var->name_size);

... better keep it compiled with a trace event:

        if (trace_event_get_state_backends(TRACE_UEFI_POLICY)) {

> -    print_policy_entry(pe);
> +    if (VARIABLE_POLICY_DEBUG) {
> +        print_policy_entry(pe);
> +    }
>   
>       if ((var->attributes & pe->attributes_must_have) != pe->attributes_must_have) {
>           trace_uefi_vars_policy_deny("must-have-attr");



  reply	other threads:[~2026-07-02 12:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  9:23 [PATCH v2 0/2] hw/uefi: security fixes Gerd Hoffmann
2026-07-02  9:23 ` [PATCH v2 1/2] hw/uefi: add sanity check Gerd Hoffmann
2026-07-02  9:23 ` [PATCH v2 2/2] hw/uefi: disable debug function Gerd Hoffmann
2026-07-02 12:56   ` Philippe Mathieu-Daudé [this message]
2026-07-06 10:49     ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a13fcae-779a-4596-bd2d-c5cd7cf8ad1f@oss.qualcomm.com \
    --to=philmd@oss.qualcomm.com \
    --cc=kraxel@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.