From: E Shattow <e@freeshell.de>
To: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>,
Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>,
Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>,
Sam Edwards <cfsworks@gmail.com>, Anshul Dalal <anshuld@ti.com>,
u-boot@lists.denx.de
Subject: Re: [PATCH 2/2] common/spl: guard against buffer overflow in spl_fit_get_image_name()
Date: Tue, 24 Jun 2025 19:18:35 -0700 [thread overview]
Message-ID: <a8aee479-3379-4947-b388-b6fdadef8a04@freeshell.de> (raw)
In-Reply-To: <20250624153431.46986-3-heinrich.schuchardt@canonical.com>
On 6/24/25 08:34, Heinrich Schuchardt wrote:
> A malformed FIT image could have an image name property that is not NUL
> terminated. Reject such images.
>
> Reported-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> common/spl/spl_fit.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index e250c11ebbd..25f3c822a49 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -73,7 +73,7 @@ static int spl_fit_get_image_name(const struct spl_fit_info *ctx,
> const char **outname)
> {
> struct udevice *sysinfo;
> - const char *name, *str;
> + const char *name, *str, *end;
> __maybe_unused int node;
> int len, i;
> bool found = true;
> @@ -83,11 +83,17 @@ static int spl_fit_get_image_name(const struct spl_fit_info *ctx,
> debug("cannot find property '%s': %d\n", type, len);
> return -EINVAL;
> }
> + /* A string property should be NUL terminated */
> + end = name + len - 1;
> + if (!len || *end) {
> + debug("malformed property '%s'\n", type);
> + return -EINVAL;
> + }
>
> str = name;
> for (i = 0; i < index; i++) {
> str = strchr(str, '\0') + 1;
> - if (!str || (str - name >= len)) {
> + if (str > end) {
> found = false;
> break;
> }
Tested-by: E Shattow <e@freeshell.de>
next prev parent reply other threads:[~2025-06-25 2:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-24 15:34 [PATCH 0/2] spl: fix error handling in spl_fit_get_image_name() Heinrich Schuchardt
2025-06-24 15:34 ` [PATCH 1/2] common/spl: Revert fix potential out of buffer access in spl_fit_get_image_name function Heinrich Schuchardt
2025-06-25 2:18 ` E Shattow
2025-06-24 15:34 ` [PATCH 2/2] common/spl: guard against buffer overflow in spl_fit_get_image_name() Heinrich Schuchardt
2025-06-24 21:02 ` Mikhail Kshevetskiy
2025-06-24 23:05 ` Heinrich Schuchardt
2025-06-24 21:05 ` Mikhail Kshevetskiy
2025-06-24 23:05 ` Heinrich Schuchardt
2025-06-24 23:07 ` Mikhail Kshevetskiy
2025-06-25 2:18 ` E Shattow [this message]
2025-06-25 2:00 ` [PATCH 0/2] spl: fix error handling " E Shattow
2025-06-26 19:32 ` Tom Rini
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=a8aee479-3379-4947-b388-b6fdadef8a04@freeshell.de \
--to=e@freeshell.de \
--cc=anshuld@ti.com \
--cc=cfsworks@gmail.com \
--cc=heinrich.schuchardt@canonical.com \
--cc=mikhail.kshevetskiy@iopsys.eu \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox