Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Michał Grzelak" <michal.grzelak@linux.intel.com>,
	intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v1 2/2] drm/i915/bios: check if VBT#57's tables are zeroed
Date: Thu, 26 Nov 2026 18:04:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-235989@kernel.org> (raw)
In-Reply-To: <20261126175033.181407-3-michal.grzelak@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/i915/bios: whole-block zero check in
  parse_vswing_preemph_override()
- [Medium] drm/i915/bios: u32 underflow in
  parse_vswing_preemph_override() size check
--

commit 8d486a542cefe34b382644665b58bbe94c62cdf9
Author: Michał Grzelak <michal.grzelak@linux.intel.com>

drm/i915/bios: check if VBT#57's tables are zeroed

This commit skips storing VBT block 57 metadata and allocating per-port
override buffers when the vswing/pre-emphasis override tables are zeroed.

> diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
> index 080a76a95136d..d27fee52bc447 100644
> --- a/drivers/gpu/drm/i915/display/intel_bios.c
> +++ b/drivers/gpu/drm/i915/display/intel_bios.c
> @@ -2227,6 +2227,12 @@ parse_vswing_preemph_override(struct intel_display *display)
>  	if (!block)
>  		return;
>  
> +	/* adjust size for num_tables and num_columns fields */
> +	if (mem_is_zero(block->tables, get_blocksize(block) - 2)) {
> +		drm_dbg_kms(display->drm, "VBT#57 tables are zeroed\n");
> +		return;
> +	}

[Severity: Medium]
Can checking the entire block->tables buffer at once still leave an
individual port with an all-zero override table when block 57 is only
partially populated?

block->tables contains multiple sub-tables indexed by PHY type and link
rate (such as tables 0..3 in intel_bios_get_c10_vspeo() and tables 4..5 in
intel_bios_get_c20_vspeo()).  If one sub-table in block 57 has non-zero
entries while the sub-table selected for another port or link rate is all
zeroes, mem_is_zero() across the whole block returns false, and
intel_bios_get_*_vspeo() still overrides the default PHY translation table
with zeroes and breaks link training.  Should the zero check be done on the
selected sub-table slice (num_rows * num_columns * sizeof(u32) bytes at
idx * num_rows * num_columns) in intel_bios_get_*_vspeo() instead?

[Severity: Medium]
Can get_blocksize(block) - 2 underflow if a malformed VBT header reports a
block size of 0 or 1?

init_bdb_block() allocates max(min_size, block_size) + 3 bytes for the BDB
entry, but copies the raw 3-byte BDB header without updating the 16-bit
size field when block_size < min_size:

drivers/gpu/drm/i915/display/intel_bios.c:init_bdb_block() {
	...
	entry = kzalloc_flex(*entry, data, max(min_size, block_size) + 3);
	...
	memcpy(entry->data, block - 3, block_size + 3);
	...
}

get_blocksize(block) returns that raw 16-bit size as a u32, so subtracting
2 without first checking get_blocksize(block) >= sizeof(*block) wraps to
0xfffffffe or 0xffffffff and passes that length to mem_is_zero(), causing
an out-of-bounds read past entry->data.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126175033.181407-1-michal.grzelak@linux.intel.com?part=2

      reply	other threads:[~2026-11-26 18:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 17:50 [PATCH v1 0/2] drm/i915/bios: vbt-related fixes Michał Grzelak
2026-11-26 17:50 ` [PATCH v1 1/2] drm/i915/bios: include whitespace into VBT signature Michał Grzelak
2026-11-26 18:01   ` sashiko-bot
2026-11-26 17:50 ` [PATCH v1 2/2] drm/i915/bios: check if VBT#57's tables are zeroed Michał Grzelak
2026-11-26 18:04   ` sashiko-bot [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=sashiko-outbox-235989@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=michal.grzelak@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox