Skip to contentSkip to conversation

x86: fix macro with bad_bios_dmi_table

PATCH Applied Yinghai Lu 3 participants 4 messages Sep 23, 2008 x86

lore
Share & tools
lore

Yinghai Lu

author
#0 lore raw

need one blank tail.

fix the crash on ingo's test box.

arch/x86/kernel/setup.c +1 -1
index a9998cb..3d677b5 100644
@@ -760,8 +760,8 @@ static struct dmi_system_id __initdata bad_bios_dmi_table[] = {
 			DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies, LTD"),
 		},
 	},
-	{}
 #endif
+	{}
 };
 
 /*
Applied
#1 lore raw
Quoted 3 lines · Yinghai Lu

need one blank tail.

fix the crash on ingo's test box.

applied to tip/x86/memory-corruption-check, thanks Yinghai!

arch/x86/kernel/setup.c static struct dmi_system_id __initdata bad_bios_dmi_table[] = { · line 765

Quoted 10 lines
arch/x86/kernel/setup.c +1 -1
@@ -760,8 +760,8 @@ static struct dmi_system_id __initdata bad_bios_dmi_table[] = {
 			DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies, LTD"),
 		},
 	},
-	{}
 #endif
+	{}
 };

i've seen such DMI crashes numerous times, caused by a missing NULL at the end of the table. Is there no sane way to detect or robustly avoid such run-off-the-end bugs?

how about changing dmi_check_system(table) to a macro, which does something like:

__dmi_check_system(&(table), sizeof(table))

and rename dmi_check_system() in drivers/firmware/dmi_scan.c to __dmi_check_system() and add the size parameter? That way we could remove the need for NULL termination and it's even a size optimization:
it shrinks those tables a tiny bit.

Ingo

#2 lore raw
Quoted 24 lines · Ingo Molnar
Quoted 3 lines · Yinghai Lu

need one blank tail.

fix the crash on ingo's test box.

applied to tip/x86/memory-corruption-check, thanks Yinghai!

arch/x86/kernel/setup.c static struct dmi_system_id __initdata bad_bios_dmi_table[] = { · line 765

Quoted 10 lines
arch/x86/kernel/setup.c +1 -1
@@ -760,8 +760,8 @@ static struct dmi_system_id __initdata bad_bios_dmi_table[] = {
                      DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies, LTD"),
              },
      },
-     {}
 #endif
+     {}
 };

i've seen such DMI crashes numerous times, caused by a missing NULL at the end of the table. Is there no sane way to detect or robustly avoid such run-off-the-end bugs?

Quoted 4 lines

how about changing dmi_check_system(table) to a macro, which does something like:

__dmi_check_system(&(table), sizeof(table))

ARRAY_SIZE()

Quoted 5 lines

and rename dmi_check_system() in drivers/firmware/dmi_scan.c to __dmi_check_system() and add the size parameter? That way we could remove the need for NULL termination and it's even a size optimization:
it shrinks those tables a tiny bit.

# git grep dmi_system_id | grep "\[" | wc -l
62

YH

#3 lore raw
Quoted 25 lines · Yinghai Lu
Quoted 24 lines · Ingo Molnar
Quoted 3 lines · Yinghai Lu

need one blank tail.

fix the crash on ingo's test box.

applied to tip/x86/memory-corruption-check, thanks Yinghai!

arch/x86/kernel/setup.c static struct dmi_system_id __initdata bad_bios_dmi_table[] = { · line 765

Quoted 10 lines
arch/x86/kernel/setup.c +1 -1
@@ -760,8 +760,8 @@ static struct dmi_system_id __initdata bad_bios_dmi_table[] = {
                      DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies, LTD"),
              },
      },
-     {}
 #endif
+     {}
 };

i've seen such DMI crashes numerous times, caused by a missing NULL at the end of the table. Is there no sane way to detect or robustly avoid such run-off-the-end bugs?

Quoted 6 lines
Quoted 4 lines

how about changing dmi_check_system(table) to a macro, which does something like:

__dmi_check_system(&(table), sizeof(table))

ARRAY_SIZE()

yes.

Quoted 7 lines
Quoted 4 lines

and rename dmi_check_system() in drivers/firmware/dmi_scan.c to __dmi_check_system() and add the size parameter? That way we could remove the need for NULL termination and it's even a size optimization:
it shrinks those tables a tiny bit.

# git grep dmi_system_id | grep "\[" | wc -l
62

what's the problem? I think in most cases dmi_check_system() is called with an actual static table so most of the dmi_check_system() callsites should work just fine and need not to be touched. (as we still keep the same API - we just redirect it to __dmi_check_system())

Ingo