Linux USB
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Daehyeon Ko <4ncienth@gmail.com>
Cc: Mika Westerberg <westeri@kernel.org>,
	Andreas Noever <andreas.noever@gmail.com>,
	Yehezkel Bernat <YehezkelShB@gmail.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] thunderbolt: Validate DP bandwidth notification port
Date: Thu, 10 Sep 2026 10:05:42 +0200	[thread overview]
Message-ID: <20260910080542.GQ106095@black.igk.intel.com> (raw)
In-Reply-To: <20260909035040.2929285-2-4ncienth@gmail.com>

Hi,

On Wed, Sep 09, 2026 at 12:50:39PM +0900, Daehyeon Ko wrote:
> The port number in a DP bandwidth notification is six bits wide and
> comes from the router. A router whose maximum port number is smaller can
> therefore make tb_handle_dp_bandwidth_request() index beyond the
> max_port_number + 1 entries allocated for sw->ports. The first
> tb_port_is_dpin() check then reads the out-of-bounds object.
> 
> Reject notifications that refer to a non-existent adapter before
> dereferencing the port.
> 
> Fixes: 6ce3563520be ("thunderbolt: Add support for DisplayPort bandwidth allocation mode")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Daehyeon Ko <4ncienth@gmail.com>
> ---
>  drivers/thunderbolt/tb.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
> index 47753a5c0f2eb..8551dafe98c8e 100644
> --- a/drivers/thunderbolt/tb.c
> +++ b/drivers/thunderbolt/tb.c
> @@ -2756,6 +2756,11 @@ static void tb_handle_dp_bandwidth_request(struct work_struct *work)
>  		goto unlock;
>  	}
>  
> +	if (ev->port > sw->config.max_port_number) {
> +		tb_sw_warn(sw, "bandwidth request from non-existent port %u\n",
> +			   ev->port);
> +		goto put_sw;

For this can you make a helper function tb_switch_port(sw, ev->port) that
issues a warning and then replace the direct access sw->ports[] with that?

> +	}
>  	in = &sw->ports[ev->port];
>  	if (!tb_port_is_dpin(in)) {
>  		tb_port_warn(in, "bandwidth request to non-DP IN adapter\n");
> -- 
> 2.55.0

  reply	other threads:[~2026-09-10  8:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09  3:50 [PATCH 0/2] thunderbolt: Validate router-provided port numbers Daehyeon Ko
2026-09-09  3:50 ` [PATCH 1/2] thunderbolt: Validate DP bandwidth notification port Daehyeon Ko
2026-09-10  8:05   ` Mika Westerberg [this message]
2026-09-09  3:50 ` [PATCH 2/2] thunderbolt: Validate output ports while discovering paths Daehyeon Ko
2026-09-09 12:21   ` 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=20260910080542.GQ106095@black.igk.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=4ncienth@gmail.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@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