smbios: ensure comparison SMBIOS string can't be paragraph aligned
Quoted 13 lines
Quoted 1 line
Quoted 1 line · Kevin O'Connor
Quoted 5 lines · Bruce Rogers
The SMBIOS anchor string _SM_ is stored within SeaBIOS to validate an SMBIOS entry point structure. There is the possibility (observed) that this comparison string ends up paragraph aligned and mistakenly found during a search for the real SMBIOS entry point. Ensure it will never end up on a paragraph boundary by storing it at odd alignment.
Thanks.
What OS was this on? It's really an OS bug as the OS needs to check both the signature and the checksum.
Quoted 8 lines
My preferred approach to addressing this would be to turn
p->anchor_stringinto a u32 and do an integer compare instead of a string compare. Although technically this can lead to the same potential issue, in practice it should not happen because SeaBIOS' init code is relocated out of the f-segment during startup (while static strings are generally not).-Kevin
This was actually flagged by the QEMU make check test in tests/bios-tables-test.c, where the code has asserts based on the first find of the _SM_ string found on a paragraph boundary in the f segment. It assumes that the string found is sufficient to identify the smbios entry point structure.
I read in http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf
where there are number of steps needed to verify the entry-point, beyond finding the anchor string. So I assume that the make check test needs to be fixed.
But I wonder if bios creators are also supposed to ensure that there is no such string findable on a paragraph boundary so as to avoid any potential confusion? I don't have expereince writing bios's so I am only guessing at that.
Bruce
Quoted 33 lines · Bruce Rogers
Quoted 13 lines
Quoted 1 line
Quoted 1 line · Kevin O'Connor
Quoted 5 lines · Bruce Rogers
The SMBIOS anchor string _SM_ is stored within SeaBIOS to validate an SMBIOS entry point structure. There is the possibility (observed) that this comparison string ends up paragraph aligned and mistakenly found during a search for the real SMBIOS entry point. Ensure it will never end up on a paragraph boundary by storing it at odd alignment.
Thanks.
What OS was this on? It's really an OS bug as the OS needs to check both the signature and the checksum.
Quoted 8 lines
My preferred approach to addressing this would be to turn
p->anchor_stringinto a u32 and do an integer compare instead of a string compare. Although technically this can lead to the same potential issue, in practice it should not happen because SeaBIOS' init code is relocated out of the f-segment during startup (while static strings are generally not).-Kevin
This was actually flagged by the QEMU make check test in
tests/bios-tables-test.c, where the code has asserts based on the first find of the _SM_ string found on a paragraph boundary in the f segment. It assumes that the string found is sufficient to identify the smbios entry point structure.I read in http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf
where there are number of steps needed to verify the entry-point, beyond finding the anchor string. So I assume that the make check test needs to be fixed.
Quoted 4 lines
But I wonder if bios creators are also supposed to ensure that there is no such string findable on a paragraph boundary so as to avoid any potential confusion? I don't have expereince writing bios's so I am only guessing at that.
I guess on physical hardware that would be mitigated by the BIOS's .rodata (or whatever the equivalent thing is called in BIOS-speak) NOT falling within 0xf0000..0xfffff :)
If there's no way to guarantee that with SeaBIOS, I suppose the qemu test could be rewritten to account for the possibility of "false positive" signatures...
--Gabriel
Quoted 39 lines · Gabriel L. Somlo
Quoted 33 lines · Bruce Rogers
Quoted 13 lines
Quoted 1 line
Quoted 1 line · Kevin O'Connor
Quoted 5 lines · Bruce Rogers
The SMBIOS anchor string _SM_ is stored within SeaBIOS to validate an SMBIOS entry point structure. There is the possibility (observed) that this comparison string ends up paragraph aligned and mistakenly found during a search for the real SMBIOS entry point. Ensure it will never end up on a paragraph boundary by storing it at odd alignment.
Thanks.
What OS was this on? It's really an OS bug as the OS needs to check both the signature and the checksum.
Quoted 8 lines
My preferred approach to addressing this would be to turn
p->anchor_stringinto a u32 and do an integer compare instead of a string compare. Although technically this can lead to the same potential issue, in practice it should not happen because SeaBIOS' init code is relocated out of the f-segment during startup (while static strings are generally not).-Kevin
This was actually flagged by the QEMU make check test in
tests/bios-tables-test.c, where the code has asserts based on the first find of the _SM_ string found on a paragraph boundary in the f segment. It assumes that the string found is sufficient to identify the smbios entry point structure.I read in http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf
where there are number of steps needed to verify the entry-point, beyond finding the anchor string. So I assume that the make check test needs to be fixed.Quoted 4 lines
But I wonder if bios creators are also supposed to ensure that there is no such string findable on a paragraph boundary so as to avoid any potential confusion? I don't have expereince writing bios's so I am only guessing at that.
Quoted 7 lines
I guess on physical hardware that would be mitigated by the BIOS's .rodata (or whatever the equivalent thing is called in BIOS-speak) NOT falling within 0xf0000..0xfffff :)
If there's no way to guarantee that with SeaBIOS, I suppose the qemu test could be rewritten to account for the possibility of "false positive" signatures...
I would do both - change SeaBIOS to (in practice) not put "_SM_" in the f-segment and change the QEMU test to not stop on the first "_SM_" it finds. SeaBIOS patch below (untested).
-Kevin
src/fw/biostables.c +1 -1
@@ -271,7 +271,7 @@ copy_smbios(void *pos)if (SMBiosAddr)return ;struct smbios_entry_point *p = pos; -if (memcmp (p->anchor_string,"_SM_" ,4 )) +if (p->signature !=SMBIOS_SIGNATURE )return ;if (checksum (pos,0x10 ) !=0 )return ;
src/fw/smbios.c +1 -1
@@ -37,7 +37,7 @@ smbios_entry_point_setup(u16 max_structure_size,struct smbios_entry_point ep;memset (&ep,0 ,sizeof (ep)); -memcpy (ep.anchor_string,"_SM_" ,4 ); + ep.signature =SMBIOS_SIGNATURE ; ep.length =0x1f ; ep.smbios_major_version =2 ; ep.smbios_minor_version =4 ;
src/std/smbios.h +3 -1
@@ -3,11 +3,13 @@#include "types.h" // u32 +#define SMBIOS_SIGNATURE 0x5f4d535f // "_SM_" +/* SMBIOS entry point -- must be written to a 16-bit aligned address between 0xf0000 and 0xfffff. */ struct smbios_entry_point { -char anchor_string[4 ]; +u32 signature;u8 checksum;u8 length;u8 smbios_major_version;
Quoted 92 lines
Quoted 1 line
Quoted 1 line · Kevin O'Connor
Quoted 23 lines · Gabriel L. Somlo
Quoted 22 lines · Bruce Rogers
Quoted 21 lines
Quoted 1 line
Quoted 1 line · Kevin O'Connor
Quoted 5 lines · Bruce Rogers
The SMBIOS anchor string _SM_ is stored within SeaBIOS to validate an SMBIOS entry point structure. There is the possibility (observed) that this comparison string ends up paragraph aligned and mistakenly found during a search for the real SMBIOS entry point. Ensure it will never end up on a paragraph boundary by storing it at odd alignment.
Thanks.
What OS was this on? It's really an OS bug as the OS needs to check both the signature and the checksum.
My preferred approach to addressing this would be to turn
p->anchor_stringinto a u32 and do an integer compare instead of a string compare. Although technically this can lead to the same potential issue, in practice it should not happen because SeaBIOS' init code is relocated out of the f-segment during startup (while static strings are generally not).-Kevin
Quoted 7 lines
Quoted 7 lines
This was actually flagged by the QEMU make check test in
tests/bios-tables-test.c, where the code has asserts based on the first find of the _SM_ string found on a paragraph boundary in the f segment. It assumes that the string found is sufficient to identify the smbios entry point structure.I read in
http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf
Quoted 9 lines
Quoted 8 lines
where there are number of steps needed to verify the entry-point, beyond finding the anchor string. So I assume that the make check test needs to be fixed.
But I wonder if bios creators are also supposed to ensure that there is no such string findable on a paragraph boundary so as to avoid any potential confusion? I don't have expereince writing bios's so I am only guessing at that.
Quoted 7 lines
I guess on physical hardware that would be mitigated by the BIOS's .rodata (or whatever the equivalent thing is called in BIOS-speak) NOT falling within 0xf0000..0xfffff :)
If there's no way to guarantee that with SeaBIOS, I suppose the qemu test could be rewritten to account for the possibility of "false positive" signatures...
I would do both - change SeaBIOS to (in practice) not put "_SM_" in the f-segment and change the QEMU test to not stop on the first "_SM_" it finds. SeaBIOS patch below (untested).
(quoted diff) +0
-1-Kevinsrc/fw/biostables.c +1
-1@@ -271,7 +271,7 @@ copy_smbios(void *pos)if (SMBiosAddr)return ;struct smbios_entry_point *p = pos; -if (memcmp (p->anchor_string,"_SM_" ,4 )) +if (p->signature !=SMBIOS_SIGNATURE )return ;if (checksum (pos,0x10 ) !=0 )return ;src/fw/smbios.c +1
-1@@ -37,7 +37,7 @@ smbios_entry_point_setup(u16 max_structure_size,struct smbios_entry_point ep;memset (&ep,0 ,sizeof (ep)); -memcpy (ep.anchor_string,"_SM_" ,4 ); + ep.signature =SMBIOS_SIGNATURE ; ep.length =0x1f ; ep.smbios_major_version =2 ; ep.smbios_minor_version =4 ;src/std/smbios.h +1
-0@@ -3,11 +3,13 @@#include "types.h" // u32 +#define SMBIOS_SIGNATURE 0x5f4d535f // "_SM_"
src/std/smbios.h line 15
Quoted 10 lines
src/std/smbios.h +2
-1+/* SMBIOS entry point -- must be written to a 16-bit aligned address between 0xf0000 and 0xfffff. */ struct smbios_entry_point { -char anchor_string[4 ]; +u32 signature;u8 checksum;u8 length;u8 smbios_major_version;
Agreed. Thanks.
Bruce