mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 20:54:03 +02:00
net: prestera: validate firmware header length
prestera_fw_hdr_parse() reads the firmware header before checking
that the firmware image contains that header.
Reject images shorter than struct prestera_fw_header before decoding the
magic and version fields.
Fixes: 4c2703dfd7 ("net: marvell: prestera: Add PCI interface support")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Acked-by: Elad Nachman <enachman@marvell.com>
Link: https://patch.msgid.link/20260731141500.1-prestera-v2-pengpeng@iscas.ac.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
3874892dd2
commit
8ae344eb54
|
|
@ -684,6 +684,9 @@ static int prestera_fw_hdr_parse(struct prestera_fw *fw)
|
|||
struct prestera_fw_header *hdr;
|
||||
u32 magic;
|
||||
|
||||
if (fw->bin->size < sizeof(*hdr))
|
||||
return -EINVAL;
|
||||
|
||||
hdr = (struct prestera_fw_header *)fw->bin->data;
|
||||
|
||||
magic = be32_to_cpu(hdr->magic_number);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user