[SeaBIOS] [PATCH] smbios: ensure comparison SMBIOS string can't be paragraph aligned

Bruce Rogers brogers at suse.com
Tue Mar 31 01:06:30 CEST 2015


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.

Signed-off-by: Bruce Rogers <brogers at suse.com>
---
 src/fw/biostables.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/fw/biostables.c b/src/fw/biostables.c
index 50a891b..b8ff86f 100644
--- a/src/fw/biostables.c
+++ b/src/fw/biostables.c
@@ -18,6 +18,9 @@
 #include "util.h" // copy_table
 #include "x86.h" // outb
 
+// ensure signature cannot be found on paragraph boundary
+const char smbios_sig_str[] __aligned(2) VARFSEG = " _SM_";
+
 struct pir_header *PirAddr VARFSEG;
 
 void
@@ -271,7 +274,7 @@ copy_smbios(void *pos)
     if (SMBiosAddr)
         return;
     struct smbios_entry_point *p = pos;
-    if (memcmp(p->anchor_string, "_SM_", 4))
+    if (memcmp(p->anchor_string, smbios_sig_str + 1, 4))
         return;
     if (checksum(pos, 0x10) != 0)
         return;
-- 
1.9.0




More information about the SeaBIOS mailing list