All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Krzysztof Karas <krzysztof.karas@intel.com>
Cc: <apoorva.singh@intel.com>, Andi Shyti <andi.shyti@kernel.org>,
	<intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH] drm/i915/gt: Prevent uninitialized pointer reads
Date: Wed, 8 Jan 2025 09:00:59 -0500	[thread overview]
Message-ID: <Z36FG040IDskc3_1@intel.com> (raw)
In-Reply-To: <65l3gngdry65oy2itvpvydorrmy54efoc3uxbhgvejcwapxz4g@ltqxje6r2snc>

On Mon, Dec 30, 2024 at 02:24:45PM +0000, Krzysztof Karas wrote:
> Hi Apoorva and Andi,
> 
> > > Initialize rq to NULL to prevent uninitialized pointer reads.
> > 
> > where is it happening?
> > 
> > Andi
> 
> There are two instances that I see:
> 1) err = fn(..., &rq); <- this probably will set the rq (at least
> looking at the functions that are used to set "fn", when calling
> "clear()"), but from the clear()'s execution perspective there are
> no guarantees that this value will be initialized.
> 
> 2) If an "err" is set and detected before "rq" is initialized, then
> there is a path that the execution might take that leads to reading
> uninitialized "rq":
> if all calls to i915_gem_object_pin_map() would result in -ENXIO,
> then the loop would exit with a "continue" and err = -ENXIO. This then
> triggers "if (err)" after the loop and takes the second "if", which
> starts by checking the value of "rq", which at this point would still
> be uninitialized.
> 
> I think this initialization removes these corner cases, so it is worth
> introducing.

To be really honest, I'm not entirely convinced of the corner cases,
but just because this function is huge and this pointer is used in
the very end, far from any of the path setting it, I believe it is
already a good reason for introducing this protection.

Also, the function can change in the future and this could be
forgotten.

So, I just pushed the patch to drm-intel-gt-next.

Thanks for the patch and review,
Rodrigo.

> 
> Krzysztof
> 

  reply	other threads:[~2025-01-08 14:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-27 11:29 [PATCH] drm/i915/gt: Prevent uninitialized pointer reads apoorva.singh
2024-12-27 12:08 ` ✗ i915.CI.BAT: failure for " Patchwork
2024-12-27 22:45 ` [PATCH] " Andi Shyti
2024-12-30 14:24   ` Krzysztof Karas
2025-01-08 14:00     ` Rodrigo Vivi [this message]
2024-12-30 14:26 ` Krzysztof Karas
2025-01-08  0:57 ` ✓ i915.CI.BAT: success for drm/i915/gt: Prevent uninitialized pointer reads (rev2) Patchwork
2025-01-08 10:03 ` ✗ i915.CI.Full: failure " Patchwork

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=Z36FG040IDskc3_1@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=andi.shyti@kernel.org \
    --cc=apoorva.singh@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=krzysztof.karas@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 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.