From: Krzysztof Kozlowski <krzk@kernel.org>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>, Markus Mayer <mmayer@broadcom.com>
Cc: Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Florian Fainelli <florian.fainelli@broadcom.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] memory: brcmstb_dpfe: validate firmware section sizes
Date: Sat, 18 Jul 2026 19:14:33 +0200 [thread overview]
Message-ID: <fca85a03-db3a-46b2-99f3-ee665f93ea5d@kernel.org> (raw)
In-Reply-To: <20260706092223.78541-1-pengpeng@iscas.ac.cn>
On 06/07/2026 11:22, Pengpeng Hou wrote:
> __verify_firmware() reads a firmware header and sums declared
> data and instruction section sizes with a trailing checksum.
>
> Require the image to contain the header and checksum, and check each
> declared section against the remaining firmware size before computing the
> final total.
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
> drivers/memory/brcmstb_dpfe.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c
> index 08d9e05b1b33..6846e3dac3d3 100644
> --- a/drivers/memory/brcmstb_dpfe.c
> +++ b/drivers/memory/brcmstb_dpfe.c
> @@ -522,6 +522,9 @@ static int __verify_firmware(struct init_data *init,
> bool is_big_endian = false;
> const u32 *chksum_ptr;
>
> + if (fw->size < sizeof(*header) + sizeof(*chksum_ptr))
> + return ERR_INVALID_SIZE;
This looks redundant, there is a check at line 546 for this, no?
> +
> if (header->magic == DPFE_BE_MAGIC)
> is_big_endian = true;
> else if (header->magic != DPFE_LE_MAGIC)
> @@ -539,6 +542,13 @@ static int __verify_firmware(struct init_data *init,
> if ((dmem_size % sizeof(u32)) != 0 || (imem_size % sizeof(u32)) != 0)
> return ERR_INVALID_SIZE;
>
> + if (dmem_size > fw->size - sizeof(*header) - sizeof(*chksum_ptr))
> + return ERR_INVALID_SIZE;
> +
> + if (imem_size > fw->size - sizeof(*header) - sizeof(*chksum_ptr) -
> + dmem_size)
> + return ERR_INVALID_SIZE;
Is this vibe coded with some tools? Look like but I see not Assisted-by
tags.
Best regards,
Krzysztof
prev parent reply other threads:[~2026-07-18 17:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 9:22 [PATCH] memory: brcmstb_dpfe: validate firmware section sizes Pengpeng Hou
2026-07-18 17:14 ` Krzysztof Kozlowski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fca85a03-db3a-46b2-99f3-ee665f93ea5d@kernel.org \
--to=krzk@kernel.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=florian.fainelli@broadcom.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmayer@broadcom.com \
--cc=pengpeng@iscas.ac.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.