From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Mika Kuoppala <mika.kuoppala@linux.intel.com>,
intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Fix vmap_batch page iterator overrun
Date: Fri, 13 Mar 2015 14:01:07 +0000 [thread overview]
Message-ID: <5502EDA3.70203@linux.intel.com> (raw)
In-Reply-To: <1426252913-5181-1-git-send-email-mika.kuoppala@intel.com>
On 03/13/2015 01:21 PM, Mika Kuoppala wrote:
> vmap_batch() calculates amount of needed pages for the mapping
> we are going to create. And it uses this page count as an
> argument for the for_each_sg_pages() macro. The macro takes the number
> of sg list entities as an argument, not the page count. So we ended
> up iterating through all the pages on the mapped object, corrupting
> memory past the smaller pages[] array.
>
> Fix this by bailing out when we have enough pages.
>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
> drivers/gpu/drm/i915/i915_cmd_parser.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c
> index 9a6da35..61ae8ff 100644
> --- a/drivers/gpu/drm/i915/i915_cmd_parser.c
> +++ b/drivers/gpu/drm/i915/i915_cmd_parser.c
> @@ -836,8 +836,11 @@ static u32 *vmap_batch(struct drm_i915_gem_object *obj,
> }
>
> i = 0;
> - for_each_sg_page(obj->pages->sgl, &sg_iter, npages, first_page)
> + for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, first_page) {
> pages[i++] = sg_page_iter_page(&sg_iter);
> + if (i == npages)
> + break;
> + }
Are you sure this manual check is needed now that you fixed
for_each_sg_page?
Pages array looks pessimistically big enough so I don't see that memory
was getting overwritten. It looks more like our sg table was not
properly terminated which made for_each_sg_page go into random memory
and return random page pointers.
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-03-13 14:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 13:21 [PATCH] drm/i915: Fix vmap_batch page iterator overrun Mika Kuoppala
2015-03-13 14:01 ` Tvrtko Ursulin [this message]
2015-03-13 14:05 ` Chris Wilson
2015-03-13 17:36 ` Daniel Vetter
2015-03-14 2:45 ` shuang.he
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=5502EDA3.70203@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=mika.kuoppala@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