intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Lucas De Marchi" <lucas.demarchi@intel.com>
Subject: Re: [Intel-gfx] [PATCH v2] drm/i915/bios: fix slab-out-of-bounds access
Date: Thu, 23 Dec 2021 12:49:46 +0200	[thread overview]
Message-ID: <87lf0by4s5.fsf@intel.com> (raw)
In-Reply-To: <20211222081654.1843211-1-jani.nikula@intel.com>

On Wed, 22 Dec 2021, Jani Nikula <jani.nikula@intel.com> wrote:
> If VBT size is not a multiple of 4, the last 4-byte store will be out of
> bounds of the allocated buffer. Spotted with KASAN. Round up the
> allocation size.
>
> v2: Use round_up() intead of roundup() as it's a power of 2 (Thomas)
>
> Reported-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Fixes: a36e7dc0af1c ("drm/i915/dg1: Read OPROM via SPI controller")
> Cc: Clint Taylor <clinton.a.taylor@intel.com>
> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Pushed, thanks for the report and review.

BR,
Jani.


> ---
>  drivers/gpu/drm/i915/display/intel_bios.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
> index 76a8f001f4c4..c7a8d517ce81 100644
> --- a/drivers/gpu/drm/i915/display/intel_bios.c
> +++ b/drivers/gpu/drm/i915/display/intel_bios.c
> @@ -2369,7 +2369,7 @@ static struct vbt_header *spi_oprom_get_vbt(struct drm_i915_private *i915)
>  	vbt_size = intel_uncore_read(&i915->uncore, PRIMARY_SPI_TRIGGER);
>  	vbt_size &= 0xffff;
>  
> -	vbt = kzalloc(vbt_size, GFP_KERNEL);
> +	vbt = kzalloc(round_up(vbt_size, 4), GFP_KERNEL);
>  	if (!vbt)
>  		goto err_not_found;

-- 
Jani Nikula, Intel Open Source Graphics Center

      parent reply	other threads:[~2021-12-23 10:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22  8:16 [Intel-gfx] [PATCH v2] drm/i915/bios: fix slab-out-of-bounds access Jani Nikula
2021-12-22  9:57 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/bios: fix slab-out-of-bounds access (rev2) Patchwork
2021-12-22 11:34 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/bios: fix slab-out-of-bounds access (rev3) Patchwork
2021-12-22 13:34 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2021-12-23 10:49 ` Jani Nikula [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=87lf0by4s5.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=thomas.hellstrom@linux.intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).