dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Krzysztof Karas" <krzysztof.karas@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915/gem: Prevent overstepping exec array boundary
Date: Fri, 11 Sep 2026 06:29:56 +0000	[thread overview]
Message-ID: <20260911062957.3BB5C1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911061145.3535489-1-krzysztof.karas@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] VMA pin leak when returning -EINVAL for parallel contexts after a secure dispatch in `eb_parse`.
--

commit 5f50a42b21cf667f0838c20a62d465078d28fa60
Author: Krzysztof Karas <krzysztof.karas@intel.com>

drm/i915/gem: Prevent overstepping exec array boundary
    
It is possible for eb_relocate_parse_slow() to call kvfree() on
entries outside the original exec array. To amend this problem, ensure
that relocation cleanup uses the original exec object count, excluding
the VMAs appended by the command parser.

Cc: stable@vger.kernel.org # 5.10+
Assisted-by: GitHub-Copilot:gpt-6-astra

> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> index 1f303d4eaa4d4..d5aadced7da0c 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> @@ -1766,6 +1766,7 @@ static int eb_reinit_userptr(struct i915_execbuffer *eb)
>  
>  static noinline int eb_relocate_parse_slow(struct i915_execbuffer *eb)
>  {
> +	const unsigned int count = eb->buffer_count;
>  	bool have_copy = false;
>  	struct eb_vma *ev;

[ ... ]

> @@ -1868,7 +1869,6 @@ static noinline int eb_relocate_parse_slow(struct i915_execbuffer *eb)
>  
>  out:
>  	if (have_copy) {
> -		const unsigned int count = eb->buffer_count;
>  		unsigned int i;
>  
>  		for (i = 0; i < count; i++) {

[Severity: High]
This isn't a bug introduced by this patch, but while reviewing the
command parsing paths, I noticed a potential VMA pin leak in eb_parse()
when handling parallel contexts after a secure dispatch.

In eb_parse(), eb_dispatch_secure() pins a GGTT VMA and returns it as batch.
If intel_context_is_parallel() evaluates to true, the function immediately
returns -EINVAL:

drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:eb_parse() {
	...
secure_batch:
	if (batch) {
		if (intel_context_is_parallel(eb->context))
			return -EINVAL;

		eb->batches[0] = &eb->vma[eb->buffer_count++];
	...
}

Since the early -EINVAL return happens before the pinned batch is added to
the eb->vma array, eb_release_vmas() will not unpin it during the error
cleanup path.

Can this leak the pin count on the GGTT VMA, tying down memory and preventing
the VMA from being unbound? Could this lead to GGTT space exhaustion if
triggered repeatedly?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260911061145.3535489-1-krzysztof.karas@intel.com?part=1

      reply	other threads:[~2026-09-11  6:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  6:11 [PATCH] drm/i915/gem: Prevent overstepping exec array boundary Krzysztof Karas
2026-09-11  6:29 ` 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=20260911062957.3BB5C1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=krzysztof.karas@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