From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>
Cc: Andreas Noever <andreas.noever@gmail.com>,
Mika Westerberg <westeri@kernel.org>,
Yehezkel Bernat <YehezkelShB@gmail.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] thunderbolt: validate DROM entry lengths
Date: Mon, 27 Jul 2026 13:34:24 +0200 [thread overview]
Message-ID: <20260727113424.GK2365036@black.igk.intel.com> (raw)
In-Reply-To: <20260706091532.77293-1-pengpeng@iscas.ac.cn>
On Mon, Jul 06, 2026 at 05:15:32PM +0800, Pengpeng Hou wrote:
> From: Pengpeng <pengpeng@iscas.ac.cn>
>
> tb_drom_parse_entries() checks that a DROM entry does not run past the
> end of the DROM, but it did not require the declared entry length to
> cover the entry header itself.
>
> Require each entry to contain its two-byte header before dispatching to
> the type-specific DROM entry parsers.
>
> Signed-off-by: Pengpeng <pengpeng@iscas.ac.cn>
Can you add your full name to the From and SoB?
> ---
> drivers/thunderbolt/eeprom.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/thunderbolt/eeprom.c b/drivers/thunderbolt/eeprom.c
> index 5681c17f82ec..270bb34aff42 100644
> --- a/drivers/thunderbolt/eeprom.c
> +++ b/drivers/thunderbolt/eeprom.c
> @@ -414,9 +414,15 @@ static int tb_drom_parse_entries(struct tb_switch *sw, size_t header_size)
> int res;
>
> while (pos < drom_size) {
> - struct tb_drom_entry_header *entry = (void *) (sw->drom + pos);
> - if (pos + 1 == drom_size || pos + entry->len > drom_size
> - || !entry->len) {
> + struct tb_drom_entry_header *entry;
> +
> + if (drom_size - pos < sizeof(*entry)) {
> + tb_sw_warn(sw, "DROM buffer overrun\n");
> + return -EIO;
> + }
> +
> + entry = (void *)(sw->drom + pos);
> + if (entry->len < sizeof(*entry) || entry->len > drom_size - pos) {
> tb_sw_warn(sw, "DROM buffer overrun\n");
> return -EIO;
> }
> --
> 2.43.0
prev parent reply other threads:[~2026-07-27 11:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 9:15 [PATCH] thunderbolt: validate DROM entry lengths Pengpeng Hou
2026-07-27 11:34 ` Mika Westerberg [this message]
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=20260727113424.GK2365036@black.igk.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=YehezkelShB@gmail.com \
--cc=andreas.noever@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pengpeng@iscas.ac.cn \
--cc=westeri@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