firmware: dmi_scan: Prevent dmi_num integer overflow
authorJean Delvare <jdelvare@suse.de>
Fri, 20 Mar 2015 08:59:47 +0000 (09:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 19 Apr 2015 08:10:21 +0000 (10:10 +0200)
commitc1caa181eb331c4ae8cddf74d283310c2198a42b
tree889de351451dfe518efa3c166ea794eb4d6057ec
parent7781f475043500175217e22bd6ad93995fa6e821
firmware: dmi_scan: Prevent dmi_num integer overflow

commit bfbaafae8519d82d10da6abe75f5766dd5b20475 upstream.

dmi_num is a u16, dmi_len is a u32, so this construct:

dmi_num = dmi_len / 4;

would result in an integer overflow for a DMI table larger than
256 kB. I've never see such a large table so far, but SMBIOS 3.0
makes it possible so maybe we'll see such tables in the future.

So instead of faking a structure count when the entry point does
not provide it, adjust the loop condition in dmi_table() to properly
deal with the case where dmi_num is not set.

This bug was introduced with the initial SMBIOS 3.0 support in commit
fc43026278b2 ("dmi: add support for SMBIOS 3.0 64-bit entry point").

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Matt Fleming <matt.fleming@intel.com>
Cc: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/firmware/dmi_scan.c