mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
net: prestera: validate firmware header length
[ Upstream commit8ae344eb54] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
43c7d0a691
commit
6fad06bb79
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user