RE: [EXTERNAL] [PATCH net v2] net: prestera: validate firmware header length

Elad Nachman <[email protected]>
Newsgroups org.kernel.vger.netdev,org.kernel.vger.linux-kernel
Message-ID <BN9PR18MB425186E93DEDDC829BD923C2DBD32@BN9PR18MB4251.namprd18.prod.outlook.com>
>
>
> 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_header before 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 tree
>
>  drivers/net/ethernet/marvell/prestera/prestera_pci.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
> index 2989a77e3b42..1ad0e62a8433 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
> @@ -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);
> --
> 2.50.1
>

Acked-by: Elad Nachman <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.