Skip to content

Commit 0ef11f6

Browse files
committed
firmware: dmi: Stop decoding on broken entry
If a DMI table entry is shorter than 4 bytes, it is invalid. Due to how DMI table parsing works, it is impossible to safely recover from such an error, so we have to stop decoding the table. Signed-off-by: Jean Delvare <jdelvare@suse.de> Link: https://lore.kernel.org/linux-kernel/Zh2K3-HLXOesT_vZ@liuwe-devbox-debian-v2/T/ Reviewed-by: Michael Kelley <mhklinux@outlook.com>
1 parent cf770af commit 0ef11f6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/firmware/dmi_scan.c

+11
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ static void dmi_decode_table(u8 *buf,
101101
(data - buf + sizeof(struct dmi_header)) <= dmi_len) {
102102
const struct dmi_header *dm = (const struct dmi_header *)data;
103103

104+
/*
105+
* If a short entry is found (less than 4 bytes), not only it
106+
* is invalid, but we cannot reliably locate the next entry.
107+
*/
108+
if (dm->length < sizeof(struct dmi_header)) {
109+
pr_warn(FW_BUG
110+
"Corrupted DMI table, offset %zd (only %d entries processed)\n",
111+
data - buf, i);
112+
break;
113+
}
114+
104115
/*
105116
* We want to know the total length (formatted area and
106117
* strings) before decoding to make sure we won't run off the

0 commit comments

Comments
 (0)