net: prestera: validate firmware header length
Subsystems (3)
PATCH v2 1/1 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.
---
Changes since v1: https://lore.kernel.org/all/[email protected]/
- target the net tree in the Subject as requested by Andrew Lunn
- rebase onto the current tree
drivers/net/ethernet/marvell/prestera/prestera_pci.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/marvell/prestera/prestera_pci.c +3 -0
@@ -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);
Signature · 1 line
2.50.1
Quoted 38 lines
From: Pengpeng Hou <[email protected]>
Sent: Friday, July 31, 2026 5:19 PM
To: Elad Nachman <[email protected]>
Cc: Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]; [email protected]; Pengpeng Hou <[email protected]>
Subject: [EXTERNAL] [PATCH net v2] 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_headerbefore decoding the magic and version fields.Signed-off-by Pengpeng Hou <mailto:[email protected]>---
Changes since v1
- target the net tree in the Subject as requested by Andrew Lunn
- rebase onto the current treedrivers/net/ethernet/marvell/prestera/prestera_pci.c | 3 +++ 1 file changed, 3 insertions(+)drivers/net/ethernet/marvell/prestera/prestera_pci.c +3
-1@@ -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); --
Quoted 2 lines
2.50.1
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Fri, 31 Jul 2026 22:19:06 +0800 you wrote:
prestera_fw_hdr_parse()reads the firmware header before checking that the firmware image contains that header.Reject images shorter than struct
prestera_fw_headerbefore decoding the magic and version fields.Signed-off-by Pengpeng Hou <[email protected]>[...]
Here is the summary with links:
- [net,v2] net: prestera: validate firmware header length
https://git.kernel.org/netdev/net/c/8ae344eb540a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html