From: Raymond Mao <raymondmaoca@gmail.com>
To: u-boot@lists.denx.de
Cc: Raymond Mao <raymond.mao@riscstar.com>,
Raymond Mao <raymondmaoca@gmail.com>,
Tom Rini <trini@konsulko.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Samuel Holland <samuel.holland@sifive.com>
Subject: [PATCH] smbios: Add an explicit bounds check for Type 9 length
Date: Tue, 7 Apr 2026 16:41:09 -0400 [thread overview]
Message-ID: <20260407204113.3102785-1-raymondmaoca@gmail.com> (raw)
From: Raymond Mao <raymond.mao@riscstar.com>
Fix Coverity Scan defect on Type 9 length.
Type 9 formatted length is built dynamically from peer_grouping_count.
Although peer_grouping_count is a byte, the resulting formatted area
still must fit in the SMBIOS header length field (u8).
Add an explicit bounds check before extending len, so the size used by
map_sysmem() and memset() is guaranteed to be valid and consistent
with hdr.length.
Fixes: a8442c226635 ("smbios: add support for dynamic generation of Type 9 system slot tables")
Addresses-Coverity-ID: CID 645487: Insecure data handling (TAINTED_SCALAR)
Signed-off-by: Raymond Mao <raymond.mao@riscstar.com>
---
lib/smbios.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/smbios.c b/lib/smbios.c
index d5f18c8bd69..18c48b15d2a 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -1093,6 +1093,9 @@ static int smbios_write_type9_1slot(ulong *current, int handle,
* TODO:
* peer_groups = <peer_grouping_count> * SMBIOS_TYPE9_PGROUP_SIZE
*/
+ if (len + pgroups_size > U8_MAX)
+ return -EINVAL;
+
len += pgroups_size;
t = map_sysmem(*current, len);
--
2.25.1
reply other threads:[~2026-04-07 20:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260407204113.3102785-1-raymondmaoca@gmail.com \
--to=raymondmaoca@gmail.com \
--cc=ilias.apalodimas@linaro.org \
--cc=raymond.mao@riscstar.com \
--cc=samuel.holland@sifive.com \
--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