Skip to content

lscpu: fix out-of-bounds read in parse_dmi_table#4431

Open
aizu-m wants to merge 1 commit into
util-linux:masterfrom
aizu-m:lscpu-dmi-oob-read
Open

lscpu: fix out-of-bounds read in parse_dmi_table#4431
aizu-m wants to merge 1 commit into
util-linux:masterfrom
aizu-m:lscpu-dmi-oob-read

Conversation

@aizu-m

@aizu-m aizu-m commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

parse_dmi_table() reads SMBIOS structure fields by fixed offset and walks their string set after validating only the 4-byte header, so a truncated final structure in the firmware DMI table is read past the end of the buffer; gate each field read on the structure length and stop once a structure no longer fits.

parse_dmi_table() walks the SMBIOS structures from the firmware DMI
table. The loop only checks that the 4-byte header fits (data + 4 <=
buf + len) and that h.length >= 4. It then reads the type 0/1/4 fields
at fixed offsets up to data[0x28] and hands the string-number bytes to
dmi_string(), which walks the structure's string set. So a truncated
final structure, where h.length, a field offset or the string set runs
past the end of the table, is read out of bounds; the bytes end up in
the CPU model/vendor strings lscpu prints. The table comes from
/sys/firmware/dmi/tables, or from /dev/mem when probing a hypervisor.

Gate each field read on h.length and stop once a structure (formatted
area plus its string set) no longer fits in the buffer, the way
dmidecode bounds these reads.

Signed-off-by: aizu-m <aizumusheer2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant