qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] smbios: sanitize type from external type before checking hav


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH] smbios: sanitize type from external type before checking have_fields_bitmap
Date: Mon, 5 Sep 2022 16:32:49 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.0

On 5/9/22 12:36, Paolo Bonzini wrote:
test_bit uses header->type as an offset; if the file incorrectly specifies a
type greater than 127, smbios_entry_add will read garbage.

To fix this, just pass the smbios data through, assuming the user knows what
to do.  Reported by Coverity as CID 1487255.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
  hw/smbios/smbios.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 60349ee402..485fa15202 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -1205,7 +1205,8 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
              return;
          }
- if (test_bit(header->type, have_fields_bitmap)) {
+        if (header->type <= SMBIOS_MAX_TYPE &&
+            test_bit(header->type, have_fields_bitmap)) {
              error_setg(errp,
                         "can't load type %d struct, fields already specified!",
                         header->type);

Completing the diff:

            return;
        }
        set_bit(header->type, have_binfile_bitmap);

Same problem  here ^^^

It seems safer to check header->type range before load_image_size().



reply via email to

[Prev in Thread] Current Thread [Next in Thread]