firmware: dmi: Fix unlikely out-of-bounds read in save_mem_devices
authorJean Delvare <jdelvare@suse.de>
Mon, 14 Oct 2019 19:41:24 +0000 (21:41 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Jan 2020 13:51:19 +0000 (14:51 +0100)
commitb79d380017d1d23b1b07c860a1adc1360a1fcb09
tree840b0637302f5ef85c5fa46d3975d8be0b099b3f
parentfc7510d80220bb0a458c328ace6be44abbf42c35
firmware: dmi: Fix unlikely out-of-bounds read in save_mem_devices

[ Upstream commit 81dde26de9c08bb04c4962a15608778aaffb3cf9 ]

Before reading the Extended Size field, we should ensure it fits in
the DMI record. There is already a record length check but it does
not cover that field.

It would take a seriously corrupted DMI table to hit that bug, so no
need to worry, but we should still fix it.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Fixes: 6deae96b42eb ("firmware, DMI: Add function to look up a handle and return DIMM size")
Cc: Tony Luck <tony.luck@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/dmi_scan.c