From: David Carlier <devnexen@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
oss-drivers@corigine.com
Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
David Carlier <devnexen@gmail.com>
Subject: [PATCH] nfp: reject truncated hwinfo table
Date: Tue, 8 Sep 2026 01:54:37 +0100 [thread overview]
Message-ID: <20260908005437.11004-1-devnexen@gmail.com> (raw)
hwinfo_db_validate() only bounds db->size from above, so a firmware
table advertising size < sizeof(*db) + sizeof(u32) makes the following
"size -= sizeof(u32)" underflow and crc32_posix() read far out of
bounds. Reject such tables before the subtraction.
Fixes: 59a8474888e9 ("nfp: add hwinfo support")
Assisted-by: Claude Opus 5 (Anthropic)
Signed-off-by: David Carlier <devnexen@gmail.com>
---
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_hwinfo.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_hwinfo.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_hwinfo.c
index cfa4db5d3f85..30aad12fd062 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_hwinfo.c
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_hwinfo.c
@@ -136,6 +136,11 @@ hwinfo_db_validate(struct nfp_cpp *cpp, struct nfp_hwinfo *db, u32 len)
return -EINVAL;
}
+ if (size < sizeof(*db) + sizeof(u32)) {
+ nfp_err(cpp, "Truncated hwinfo table, size %u\n", size);
+ return -EINVAL;
+ }
+
size -= sizeof(u32);
crc = crc32_posix(db, size);
if (crc != get_unaligned_le32(db->start + size)) {
--
2.55.0
next reply other threads:[~2026-09-08 0:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 0:54 David Carlier [this message]
2026-09-08 20:40 ` Jakub Kicinski
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=20260908005437.11004-1-devnexen@gmail.com \
--to=devnexen@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@corigine.com \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®