From: srini@kernel.org
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org,
James Hilliard <james.hilliard1@gmail.com>,
stable@vger.kernel.org, Srinivas Kandagatla <srini@kernel.org>
Subject: [PATCH 01/10] nvmem: layouts: onie-tlv: check both field header and value bounds
Date: Tue, 1 Dec 2026 23:26:48 +0000 [thread overview]
Message-ID: <20261201232657.537736-2-srini@kernel.org> (raw)
In-Reply-To: <20261201232657.537736-1-srini@kernel.org>
From: James Hilliard <james.hilliard1@gmail.com>
The table CRC does not validate individual field lengths. The field
iterator can read a two-byte header when only one byte remains. Its
value length check also counts the header as available space and can
publish a cell extending beyond the table.
Check the remaining space before reading the header and exclude the
header from the space available for the value. Stop at the first
truncated field, keeping any complete cells already registered.
Fixes: d3c0d12f6474 ("nvmem: layouts: onie-tlv: Add new layout driver")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/sashiko-outbox-219531@kernel.org/
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
---
drivers/nvmem/layouts/onie-tlv.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/nvmem/layouts/onie-tlv.c b/drivers/nvmem/layouts/onie-tlv.c
index 4da3a704388e..1e397565b928 100644
--- a/drivers/nvmem/layouts/onie-tlv.c
+++ b/drivers/nvmem/layouts/onie-tlv.c
@@ -110,8 +110,15 @@ static int onie_tlv_add_cells(struct device *dev, struct nvmem_device *nvmem,
return -ENOENT;
while (offset < data_len) {
+ size_t remaining = data_len - offset;
+
+ if (remaining < sizeof(tlv)) {
+ dev_err(dev, "Truncated field header at 0x%x\n", hdr_len + offset);
+ break;
+ }
+
memcpy(&tlv, data + offset, sizeof(tlv));
- if (offset + tlv.len >= data_len) {
+ if (tlv.len > remaining - sizeof(tlv)) {
dev_err(dev, "Out of bounds field (0x%x bytes at 0x%x)\n",
tlv.len, hdr_len + offset);
break;
--
2.53.0
next prev parent reply other threads:[~2026-12-01 23:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 23:26 [PATCH 00/10] nvmem: fixes for v7.4 srini
2026-12-01 23:26 ` srini [this message]
2026-12-01 23:26 ` [PATCH 02/10] nvmem: core: validate DT cell bits before allocating the name srini
2026-12-01 23:26 ` [PATCH 03/10] nvmem: retain the provider node until device release srini
2026-12-01 23:26 ` [PATCH 04/10] nvmem: drain keepout and cell post-processing accesses srini
2026-12-01 23:26 ` [PATCH 05/10] nvmem: exclude disconnected providers from callback admission srini
2026-12-01 23:26 ` [PATCH 06/10] nvmem: release write protection when the provider disconnects srini
2026-12-01 23:26 ` [PATCH 07/10] nvmem: airoha-smc-efuses: Fix the SMC function ID for eFuse read srini
2026-12-01 23:26 ` [PATCH 08/10] nvmem: imx-ocotp-scu: assign nvmem_cell_info::raw_len srini
2026-12-01 23:26 ` [PATCH 09/10] nvmem: core: reject reads and writes beyond the device size srini
2026-12-01 23:26 ` [PATCH 10/10] nvmem: sprd: fix out-of-bounds read in sprd_efuse_read() srini
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=20261201232657.537736-2-srini@kernel.org \
--to=srini@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=james.hilliard1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®