2015-02-04 13:58:21

by Ivan Khoronzhuk

[permalink] [raw]
Subject: [Patch] firmware: dmi_scan: fix dmi scan to handle "End of Table" structure

The dmi-sysfs should create "End of Table" entry, that is type 127.
But after adding initial SMBIOS v3 support the 127-0 entry is not
handled any more, as result it's not created in sysfs.
This is important because the size of whole DMI table must correspond
to sum of all DMI entry sizes.

Of-course, it can be handled in newly introduced libdmifs by adding
end entry virtually, but it's brake backward compatibility and don't
correspond to SMBIOS DMI table size read from SMBIOS entry point
structure.

Signed-off-by: Ivan Khoronzhuk <[email protected]>
---
drivers/firmware/dmi_scan.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index c5f7b4e..c63e5e5 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -93,12 +93,6 @@ static void dmi_table(u8 *buf, int len, int num,
const struct dmi_header *dm = (const struct dmi_header *)data;

/*
- * 7.45 End-of-Table (Type 127) [SMBIOS reference spec v3.0.0]
- */
- if (dm->type == DMI_ENTRY_END_OF_TABLE)
- break;
-
- /*
* We want to know the total length (formatted area and
* strings) before decoding to make sure we won't run off the
* table in dmi_decode or dmi_string
--
1.9.1


2015-02-04 14:04:46

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: [Patch] firmware: dmi_scan: fix dmi scan to handle "End of Table" structure

On 4 February 2015 at 13:57, Ivan Khoronzhuk <[email protected]> wrote:
> The dmi-sysfs should create "End of Table" entry, that is type 127.
> But after adding initial SMBIOS v3 support the 127-0 entry is not
> handled any more, as result it's not created in sysfs.
> This is important because the size of whole DMI table must correspond
> to sum of all DMI entry sizes.
>
> Of-course, it can be handled in newly introduced libdmifs by adding
> end entry virtually, but it's brake backward compatibility and don't
> correspond to SMBIOS DMI table size read from SMBIOS entry point
> structure.
>
> Signed-off-by: Ivan Khoronzhuk <[email protected]>
> ---
> drivers/firmware/dmi_scan.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
> index c5f7b4e..c63e5e5 100644
> --- a/drivers/firmware/dmi_scan.c
> +++ b/drivers/firmware/dmi_scan.c
> @@ -93,12 +93,6 @@ static void dmi_table(u8 *buf, int len, int num,
> const struct dmi_header *dm = (const struct dmi_header *)data;
>
> /*
> - * 7.45 End-of-Table (Type 127) [SMBIOS reference spec v3.0.0]
> - */
> - if (dm->type == DMI_ENTRY_END_OF_TABLE)
> - break;
> -
> - /*
> * We want to know the total length (formatted area and
> * strings) before decoding to make sure we won't run off the
> * table in dmi_decode or dmi_string

This is not the right way to fix this: the end-of-table check needs to
be done, because the v3 entry point does not contain the actual length
of the data, but only an upper bound, and there may be trailing
garbage.

So apparently, I put this check and break in the wrong place, and we
should place it after the decode() call instead, but not remove it.

--
Ard.

2015-02-04 14:06:20

by Ivan Khoronzhuk

[permalink] [raw]
Subject: Re: [Patch] firmware: dmi_scan: fix dmi scan to handle "End of Table" structure


On 02/04/2015 04:04 PM, Ard Biesheuvel wrote:
> On 4 February 2015 at 13:57, Ivan Khoronzhuk <[email protected]> wrote:
>> The dmi-sysfs should create "End of Table" entry, that is type 127.
>> But after adding initial SMBIOS v3 support the 127-0 entry is not
>> handled any more, as result it's not created in sysfs.
>> This is important because the size of whole DMI table must correspond
>> to sum of all DMI entry sizes.
>>
>> Of-course, it can be handled in newly introduced libdmifs by adding
>> end entry virtually, but it's brake backward compatibility and don't
>> correspond to SMBIOS DMI table size read from SMBIOS entry point
>> structure.
>>
>> Signed-off-by: Ivan Khoronzhuk <[email protected]>
>> ---
>> drivers/firmware/dmi_scan.c | 6 ------
>> 1 file changed, 6 deletions(-)
>>
>> diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
>> index c5f7b4e..c63e5e5 100644
>> --- a/drivers/firmware/dmi_scan.c
>> +++ b/drivers/firmware/dmi_scan.c
>> @@ -93,12 +93,6 @@ static void dmi_table(u8 *buf, int len, int num,
>> const struct dmi_header *dm = (const struct dmi_header *)data;
>>
>> /*
>> - * 7.45 End-of-Table (Type 127) [SMBIOS reference spec v3.0.0]
>> - */
>> - if (dm->type == DMI_ENTRY_END_OF_TABLE)
>> - break;
>> -
>> - /*
>> * We want to know the total length (formatted area and
>> * strings) before decoding to make sure we won't run off the
>> * table in dmi_decode or dmi_string
> This is not the right way to fix this: the end-of-table check needs to
> be done, because the v3 entry point does not contain the actual length
> of the data, but only an upper bound, and there may be trailing
> garbage.
>
> So apparently, I put this check and break in the wrong place, and we
> should place it after the decode() call instead, but not remove it.
>

Ok.
I'll send v2.