From: Jani Nikula <jani.nikula@linux.intel.com>
To: Sebastian Brzezinka <sebastian.brzezinka@intel.com>,
intel-gfx@lists.freedesktop.org
Cc: chris.p.wilson@intel.com, andi.shyti@linux.intel.com,
krzysztof.niemiec@intel.com, krzysztof.karas@intel.com
Subject: Re: [PATCH] drm/i915: Add sanity check for relocation entry pointer in execbuffer
Date: Tue, 17 Jun 2025 13:01:54 +0300 [thread overview]
Message-ID: <e95014e59bf175fec6d3b2b53422dcf4a5a5fdd9@intel.com> (raw)
In-Reply-To: <lofb2i4actwlvfk6xbtihirrc34j3pb6xecvcl433a2xbm7zy6@akz3ko2bh2i5>
On Mon, 16 Jun 2025, Sebastian Brzezinka <sebastian.brzezinka@intel.com> wrote:
> This patch adds a defensive check in `eb_relocate_entry()` to validate
> the relocation entry pointer before dereferencing it. It ensures the
> pointer is non-NULL and accessible from userspace using `access_ok()`.
>
> This prevents potential kernel crashes caused by invalid or non-canonical
> pointers passed from userspace.
>
> If the pointer is invalid, an error is logged and the
> function returns -EFAULT.
>
> The failure was observed on a Tiger Lake system while running the IGT
> test `igt@gem_exec_big@single`. An appropriate patch has also been
> submitted to fix the issue on the IGT side.
I don't know if the patch at hand is the right thing to do (I mean I
don't know that it *isn't* either), but some comments nonetheless.
>
> Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11713
>
Superfluous newline. Please keep the trailer lines together.
> Signed-off-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> index ca7e9216934a..8056dea0e656 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> @@ -1427,6 +1427,12 @@ eb_relocate_entry(struct i915_execbuffer *eb,
> struct eb_vma *target;
> int err;
>
> + /* Sanity check for non-canonical or NULL pointer */
Is this comment helpful to the reader?
> + if (!reloc || !access_ok(reloc, sizeof(*reloc))) {
> + DRM_ERROR("Invalid relocation entry pointer: %p\n", reloc);
drm_err() please.
> + return -EFAULT;
> + }
> +
> /* we've already hold a reference to all valid objects */
> target = eb_get_vma(eb, reloc->target_handle);
> if (unlikely(!target))
--
Jani Nikula, Intel
next prev parent reply other threads:[~2025-06-17 10:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-16 14:22 [PATCH] drm/i915: Add sanity check for relocation entry pointer in execbuffer Sebastian Brzezinka
2025-06-17 10:01 ` Jani Nikula [this message]
2025-06-17 11:39 ` Tvrtko Ursulin
2025-06-18 10:15 ` Sebastian Brzezinka
2025-06-17 12:19 ` ✗ i915.CI.BAT: failure for " Patchwork
2025-06-17 13:11 ` [PATCH] " kernel test robot
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=e95014e59bf175fec6d3b2b53422dcf4a5a5fdd9@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=andi.shyti@linux.intel.com \
--cc=chris.p.wilson@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=krzysztof.karas@intel.com \
--cc=krzysztof.niemiec@intel.com \
--cc=sebastian.brzezinka@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.