From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Michael Bommarito <michael.bommarito@gmail.com>
Cc: Mika Westerberg <westeri@kernel.org>,
linux-usb@vger.kernel.org,
Andreas Noever <andreas.noever@gmail.com>,
Yehezkel Bernat <YehezkelShB@gmail.com>,
Michael Jamet <michael.jamet@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v3 2/4] thunderbolt: property: reject dir_len < 4 to prevent size_t underflow
Date: Mon, 4 May 2026 11:59:02 +0300 [thread overview]
Message-ID: <afhf1nyYlzy4Xm6q@ashevche-desk.local> (raw)
In-Reply-To: <e3c84da6e0c1defbb07e712939df0db1b2019fff.1777817011.git.michael.bommarito@gmail.com>
On Sun, May 03, 2026 at 10:15:06AM -0400, Michael Bommarito wrote:
> On the non-root path, __tb_property_parse_dir() takes dir_len from
> entry->length (u16 widened to size_t). Two distinct OOB conditions
> follow when entry->length < 4:
>
> 1. The non-root path begins with kmemdup(&block[dir_offset],
> sizeof(*dir->uuid), ...) which always reads 4 dwords from
> dir_offset. tb_property_entry_valid() only enforces
> dir_offset + entry->length <= block_len, so a crafted entry
> with dir_offset close to the end of the property block and
> entry->length in 0..3 passes that gate but lets the UUID copy
> run off the block (e.g. dir_offset = 497, dir_len = 3 in a
> 500-dword block reads block[497..501]).
>
> 2. After the kmemdup, content_len = dir_len - 4 underflows size_t
> to ~SIZE_MAX, nentries becomes SIZE_MAX / 4, and the entry
> walk runs OOB on each iteration until an entry fails
> validation or the kernel oopses on an unmapped page.
>
> Reject dir_len < 4 on the non-root path *before* the UUID kmemdup,
> which closes both holes.
>
> Also move INIT_LIST_HEAD(&dir->properties) up to immediately after
> the dir allocation so the new error-return path (and the existing
> uuid-alloc failure path) calling tb_property_free_dir() sees a
> walkable list rather than the zero-initialized NULL next/prev that
> list_for_each_entry_safe() would oops on.
...
> dir = kzalloc_obj(*dir);
> if (!dir)
> return NULL;
+ blank line.
> + INIT_LIST_HEAD(&dir->properties);
>
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-05-04 8:59 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 3:23 [PATCH 0/2] thunderbolt: harden XDomain property parser Michael Bommarito
2026-04-15 3:23 ` [PATCH 1/2] thunderbolt: property: harden XDomain property parser against crafted peer Michael Bommarito
2026-04-15 4:52 ` Mika Westerberg
2026-04-15 11:41 ` Michael Bommarito
2026-04-15 3:23 ` [PATCH 2/2] thunderbolt: test: add KUnit regression tests for XDomain property parser Michael Bommarito
2026-04-15 12:32 ` [PATCH v2 0/4] thunderbolt: harden " Michael Bommarito
2026-04-15 12:32 ` [PATCH v2 1/4] thunderbolt: property: reject u32 wrap in tb_property_entry_valid() Michael Bommarito
2026-04-27 5:35 ` Mika Westerberg
2026-05-02 17:55 ` Michael Bommarito
2026-04-15 12:32 ` [PATCH v2 2/4] thunderbolt: property: reject dir_len < 4 to prevent size_t underflow Michael Bommarito
2026-04-15 12:32 ` [PATCH v2 3/4] thunderbolt: property: cap recursion depth in __tb_property_parse_dir() Michael Bommarito
2026-04-15 12:32 ` [PATCH v2 4/4] thunderbolt: test: add KUnit regression tests for XDomain property parser Michael Bommarito
2026-04-27 5:40 ` Mika Westerberg
2026-05-03 14:15 ` [PATCH v3 0/4] thunderbolt: harden " Michael Bommarito
2026-05-03 14:15 ` [PATCH v3 1/4] thunderbolt: property: reject u32 wrap in tb_property_entry_valid() Michael Bommarito
2026-05-04 8:57 ` Andy Shevchenko
2026-05-03 14:15 ` [PATCH v3 2/4] thunderbolt: property: reject dir_len < 4 to prevent size_t underflow Michael Bommarito
2026-05-04 8:59 ` Andy Shevchenko [this message]
2026-05-03 14:15 ` [PATCH v3 3/4] thunderbolt: property: cap recursion depth in __tb_property_parse_dir() Michael Bommarito
2026-05-04 9:01 ` Andy Shevchenko
2026-05-04 12:54 ` Michael Bommarito
2026-05-03 14:15 ` [PATCH v3 4/4] thunderbolt: test: add KUnit regression tests for XDomain property parser Michael Bommarito
2026-05-05 11:48 ` Mika Westerberg
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=afhf1nyYlzy4Xm6q@ashevche-desk.local \
--to=andriy.shevchenko@linux.intel.com \
--cc=YehezkelShB@gmail.com \
--cc=andreas.noever@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=michael.bommarito@gmail.com \
--cc=michael.jamet@intel.com \
--cc=stable@vger.kernel.org \
--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