From: Laszlo Ersek <lersek@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
qemu-arm@nongnu.org, "Igor Mammedov" <imammedo@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <rth@twiddle.net>
Subject: Re: [PATCH v3 2/3] hw/smbios: report error if table size is too large
Date: Thu, 24 Sep 2020 09:13:51 +0200 [thread overview]
Message-ID: <a8943b74-e878-1104-c4cd-ae39d42f0da0@redhat.com> (raw)
In-Reply-To: <20200923133804.2089190-3-berrange@redhat.com>
On 09/23/20 15:38, Daniel P. Berrangé wrote:
> The SMBIOS 2.1 entry point uses a uint16 data type for reporting the
> total length of the tables. If the user passes -smbios configuration to
> QEMU that causes the table size to exceed this limit then various bad
> behaviours result, including
>
> - firmware hangs in an infinite loop
> - firmware triggers a KVM crash on bad memory access
> - firmware silently discards user's SMBIOS data replacing it with
> a generic data set.
>
> Limiting the size to 0xffff in QEMU avoids triggering most of these
> problems. There is a remaining bug in SeaBIOS which tries to prepend its
> own data for table 0, and does not check whether there is sufficient
> space before attempting this.
>
> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> hw/smbios/smbios.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
> index d993448087..8b30906e50 100644
> --- a/hw/smbios/smbios.c
> +++ b/hw/smbios/smbios.c
> @@ -365,6 +365,13 @@ static void smbios_register_config(void)
>
> opts_init(smbios_register_config);
>
> +/*
> + * The SMBIOS 2.1 "structure table length" field in the
> + * entry point uses a 16-bit integer, so we're limited
> + * in total table size
> + */
> +#define SMBIOS_21_MAX_TABLES_LEN 0xffff
> +
> static void smbios_validate_table(MachineState *ms)
> {
> uint32_t expect_t4_count = smbios_legacy ?
> @@ -375,6 +382,13 @@ static void smbios_validate_table(MachineState *ms)
> expect_t4_count, smbios_type4_count);
> exit(1);
> }
> +
> + if (smbios_ep_type == SMBIOS_ENTRY_POINT_21 &&
> + smbios_tables_len > SMBIOS_21_MAX_TABLES_LEN) {
> + error_report("SMBIOS 2.1 table length %zu exceeds %d",
> + smbios_tables_len, SMBIOS_21_MAX_TABLES_LEN);
> + exit(1);
> + }
> }
>
>
>
Tested-by: Laszlo Ersek <lersek@redhat.com>
next prev parent reply other threads:[~2020-09-24 7:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-23 13:38 [PATCH v3 0/3] Add support for loading SMBIOS OEM strings from a file Daniel P. Berrangé
2020-09-23 13:38 ` [PATCH v3 1/3] hw/smbios: support loading OEM strings values " Daniel P. Berrangé
2020-09-24 7:20 ` Laszlo Ersek
2020-09-23 13:38 ` [PATCH v3 2/3] hw/smbios: report error if table size is too large Daniel P. Berrangé
2020-09-24 7:13 ` Laszlo Ersek [this message]
2020-09-23 13:38 ` [PATCH v3 3/3] qemu-options: document SMBIOS type 11 settings Daniel P. Berrangé
2020-09-23 15:17 ` Markus Armbruster
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=a8943b74-e878-1104-c4cd-ae39d42f0da0@redhat.com \
--to=lersek@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).