From: "Ivan.khoronzhuk" <ivan.khoronzhuk@globallogic.com>
To: Jean Delvare <jdelvare@suse.de>, LKML <linux-kernel@vger.kernel.org>
Cc: Roy Franz <roy.franz@linaro.org>, Matt Fleming <matt.fleming@intel.com>
Subject: Re: [PATCH] firmware: dmi_scan: Trim DMI table length before exporting it
Date: Mon, 27 Apr 2015 18:17:15 +0300 [thread overview]
Message-ID: <553E52FB.7040809@globallogic.com> (raw)
In-Reply-To: <20150426224726.19888863@endymion.delvare>
Hi, Jean
On 26.04.15 23:47, Jean Delvare wrote:
> The SMBIOS v3 entry points specify a maximum length for the DMI table,
> not the exact length. Thus there may be garbage after the end-of-table
> marker, which we don't want to export to user-space. Adjust dmi_len
> when we find the end-of-table marker, so that only the actual table
> payload is exported.
According to above it seems that change doesn't affect SMBIOS < 3.
>
> Signed-off-by: Jean Delvare <jdelvare@suse.de>
> Cc: Ivan Khoronzhuk <ivan.khoronzhuk@globallogic.com>
> ---
> drivers/firmware/dmi_scan.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> --- linux-4.1-rc0.orig/drivers/firmware/dmi_scan.c 2015-04-26 18:56:15.657111185 +0200
> +++ linux-4.1-rc0/drivers/firmware/dmi_scan.c 2015-04-26 22:42:59.183547584 +0200
> @@ -108,15 +108,19 @@ static void dmi_decode_table(u8 *buf,
> if (data - buf < dmi_len - 1)
> decode(dm, private_data);
>
> + data += 2;
> + i++;
> +
> /*
> * 7.45 End-of-Table (Type 127) [SMBIOS reference spec v3.0.0]
> */
> if (dm->type == DMI_ENTRY_END_OF_TABLE)
> break;
> -
> - data += 2;
> - i++;
> }
> +
> + /* Trim DMI table length if needed */
> + if (dmi_len > data - buf)
> + dmi_len = data - buf;
Why is it checked here? Wouldn't be better to simply assign: dmi_len =
data - buf;
I guess it's supposed to not trim table in case of exit by i<dmi_num or
even !dmi_num.
But in this case, probably, it be better to do it in the cycle:
if (dmi->type == DMI_ENTRY_END_OF_TABLE) {
dmi_len = data - buf;
break;
}
just to avoid redundant check.
But question is, what if we exit by i<dmi_num?
Wouldn't be better to trim buffer in such case also?
> }
>
> static phys_addr_t dmi_base;
> @@ -125,8 +129,9 @@ static int __init dmi_walk_early(void (*
> void *))
> {
> u8 *buf;
> + u32 orig_dmi_len = dmi_len;
>
> - buf = dmi_early_remap(dmi_base, dmi_len);
> + buf = dmi_early_remap(dmi_base, orig_dmi_len);
> if (buf == NULL)
> return -1;
>
> @@ -134,7 +139,7 @@ static int __init dmi_walk_early(void (*
>
> add_device_randomness(buf, dmi_len);
>
> - dmi_early_unmap(buf, dmi_len);
> + dmi_early_unmap(buf, orig_dmi_len);
> return 0;
> }
>
>
--
Regards,
Ivan Khoronzhuk
next prev parent reply other threads:[~2015-04-27 15:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-26 20:47 Jean Delvare
2015-04-27 15:17 ` Ivan.khoronzhuk [this message]
2015-04-28 14:28 ` Jean Delvare
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=553E52FB.7040809@globallogic.com \
--to=ivan.khoronzhuk@globallogic.com \
--cc=jdelvare@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fleming@intel.com \
--cc=roy.franz@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome