efi: apple-properties: validate setup data header length

map_properties() remaps the Apple properties setup_data payload
and then reads the properties header fields.

Reject a truncated payload before checking the header version and length
fields.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
Pengpeng Hou
2026-07-06 17:18:13 +08:00
committed by Ard Biesheuvel
parent 01787ed2fd
commit eb01ffabeb

View File

@@ -207,7 +207,10 @@ static int __init map_properties(void)
}
properties = (struct properties_header *)data->data;
if (properties->version != 1) {
if (data_len < sizeof(*properties)) {
pr_err("truncated properties header\n");
ret = -EINVAL;
} else if (properties->version != 1) {
pr_err("unsupported version:\n");
print_hex_dump(KERN_ERR, pr_fmt(), DUMP_PREFIX_OFFSET,
16, 1, properties, data_len, true);