All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hari Mishal" <harimishal1@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/amd/display: fix division by zero in get_estimated_bw()
Date: Sat, 22 Aug 2026 15:15:42 +0000	[thread overview]
Message-ID: <20260822151543.30A0C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260822145751.42328-1-harimishal1@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Uncapped request_bw is assigned to allocated_bw, causing an oversized value that leads to an integer underflow during bandwidth validation.
--

--- Patch [1]: [PATCH] drm/amd/display: fix division by zero in get_estimated_bw() ---
commit d3870b3b2da2897f934f4033da62b969b6443914
Author: Hari Mishal <harimishal1@gmail.com>

drm/amd/display: fix division by zero in get_estimated_bw()

This commit fixes a division by zero in get_estimated_bw() by returning 0
if bw_granularity is zero. This prevents a crash when a connected DPIA
device reports an estimated bandwidth change before reporting a capability
change.

>     link_dpia_send_bw_alloc_request() already guards the same
>     bw_granularity division; add the identical guard here rather than
>     introducing a new pattern.

[Severity: High]
This is a pre-existing issue, but since the commit message references 
link_dpia_send_bw_alloc_request(), I noticed a potential integer underflow
issue involving allocated_bw.

In link_dpia_send_bw_alloc_request(), the uncapped request_bw variable
is assigned to allocated_bw:

drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_dpia_bw.c:link_dpia_send_bw_alloc_request() {
    ...
		temp = req_bw * link->dpia_bw_alloc_config.bw_granularity;
		request_reg_val = temp / Kbps_TO_Gbps;
		if (temp % Kbps_TO_Gbps)
			++request_reg_val;
	}

	link->dpia_bw_alloc_config.allocated_bw = request_bw;
    ...
}

Later, in link_dpia_validate_dp_tunnel_bandwidth(), remaining_bw is
calculated using unsigned 32-bit subtraction:

drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_dpia_bw.c:link_dpia_validate_dp_tunnel_bandwidth() {
    ...
			if (router_sets[j].cm_id == dp_tunnel_settings->cm_id) {
				uint32_t remaining_bw =
					dp_tunnel_settings->estimated_bw - dp_tunnel_settings->allocated_bw;
    ...
}

If a connected DPIA display requests more bandwidth than estimated,
allocated_bw will be strictly greater than estimated_bw.

Could this cause the subtraction to underflow to an extremely large
positive value (~4.29 billion), thereby bypassing the subsequent
capacity checks (required_bw > total_bw) and allowing illegal
configurations that oversubscribe the DP tunnel?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260822145751.42328-1-harimishal1@gmail.com?part=1

  reply	other threads:[~2026-08-22 15:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-22 14:57 [PATCH] drm/amd/display: fix division by zero in get_estimated_bw() Hari Mishal
2026-08-22 15:15 ` sashiko-bot [this message]
2026-08-28 20:41 ` Alex Hung

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=20260822151543.30A0C1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=harimishal1@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.