All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
To: Tvrtko Ursulin <tursulin@ursulin.net>, <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: Wed, 18 Jun 2025 10:15:49 +0000	[thread overview]
Message-ID: <DAPKX3Q0UWH8.35IG9NUP8K0ZJ@intel.com> (raw)
In-Reply-To: <3e0562fd-ccfa-493b-b1af-601081a9d0b3@ursulin.net>

Hi Tvrtko,

On Tue Jun 17, 2025 at 11:39 AM UTC, Tvrtko Ursulin wrote:
>
> On 16/06/2025 15:22, Sebastian Brzezinka 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.
>> 
>> Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11713
>> 
>> 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 */
>> +	if (!reloc || !access_ok(reloc, sizeof(*reloc))) {
>
> It doesn't look reloc is an user pointer - otherwise there wouldn't be 
> simply dereferenced just below. So something looks dodgy here, you 
> probably want to dig around a bit to figure out what is really going on.

Yes, you're right, it's indeed possible to pass both kernel and userspace
pointers. I overlooked that initially. I've corrected the issue on the
IGT side, so non-canonical pointers are no longer being sent.
Additionally, I attempted to improve the handling here, though 
it still needs more work to be fully robust. Thanks for the review!

-- 
Best regards,
Sebastian


  reply	other threads:[~2025-06-18 10:16 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
2025-06-17 11:39 ` Tvrtko Ursulin
2025-06-18 10:15   ` Sebastian Brzezinka [this message]
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=DAPKX3Q0UWH8.35IG9NUP8K0ZJ@intel.com \
    --to=sebastian.brzezinka@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=tursulin@ursulin.net \
    /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.