From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>,
"Claude Opus 4.6" <noreply@anthropic.com>
Subject: [PATCH master 2/4] FIT: fix potential underflow of stack array
Date: Mon, 16 Feb 2026 09:41:37 +0100 [thread overview]
Message-ID: <20260216084142.3546363-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20260216084142.3546363-1-a.fatoum@pengutronix.de>
Add a bounds check on depth before decrementing to prevent
stack underflow when a malformed FDT has END_NODE before BEGIN_NODE.
Reported-by: clang-analyzer 19.1.7
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/image-fit.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/common/image-fit.c b/common/image-fit.c
index 104a01b73658..a5d0a189f27c 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -153,6 +153,8 @@ static int fit_digest(struct fit_handle *handle, struct digest *digest,
case FDT_END_NODE:
dt_struct = dt_struct_advance(&f, dt_struct, FDT_TAGSIZE);
+ if (depth < 0)
+ return -ESPIPE;
include = want;
want = stack[depth--];
while (end > path && *--end != '/')
--
2.47.3
next prev parent reply other threads:[~2026-02-16 8:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-16 8:41 [PATCH master 1/4] FIT: fix potential uninitialized read during fuzzing Ahmad Fatoum
2026-02-16 8:41 ` Ahmad Fatoum [this message]
2026-02-16 8:41 ` [PATCH master 3/4] of: fdt: fix double free in fdt_ensure_space Ahmad Fatoum
2026-02-16 8:41 ` [PATCH master 4/4] of: overlay: initialize ret to fix garbage return value Ahmad Fatoum
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=20260216084142.3546363-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=noreply@anthropic.com \
/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