From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Zhou Qingyang <zhou1615@umn.edu>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>,
dri-devel@lists.freedesktop.org, David Airlie <airlied@linux.ie>,
intel-gfx@lists.freedesktop.org, kjlu@umn.edu,
linux-kernel@vger.kernel.org,
Chris Wilson <chris@chris-wilson.co.uk>,
Matthew Auld <matthew.auld@intel.com>,
Zhihao Cheng <chengzhihao1@huawei.com>
Subject: Re: [Intel-gfx] [PATCH] drm/i915/gem: Fix a NULL pointer dereference in igt_request_rewind()
Date: Tue, 30 Nov 2021 14:58:18 +0000 [thread overview]
Message-ID: <a5f5c675-0a7a-8049-d9d6-185cf4f2d91b@linux.intel.com> (raw)
In-Reply-To: <20211130141545.153899-1-zhou1615@umn.edu>
On 30/11/2021 14:15, Zhou Qingyang wrote:
> In igt_request_rewind(), mock_context(i915, "A") is assigned to ctx[0]
> and used in i915_gem_context_get_engine(). There is a dereference
> of ctx[0] in i915_gem_context_get_engine(), which could lead to a NULL
> pointer dereference on failure of mock_context(i915, "A") .
>
> So as mock_context(i915, "B").
>
> Although this bug is not serious for it belongs to testing code, it is
> better to be fixed to avoid unexpected failure in testing.
>
> Fix this bugs by adding checks about ctx[0] and ctx[1].
>
> This bug was found by a static analyzer. The analysis employs
> differential checking to identify inconsistent security operations
> (e.g., checks or kfrees) between two code paths and confirms that the
> inconsistent operations are not recovered in the current function or
> the callers, so they constitute bugs.
>
> Note that, as a bug found by static analysis, it can be a false
> positive or hard to trigger. Multiple researchers have cross-reviewed
> the bug.
>
> Builds with CONFIG_DRM_I915_SELFTEST=y show no new warnings,
> and our static analyzer no longer warns about this code.
>
> Fixes: ca883c304f54 ("drm/i915/selftests: Pass intel_context to mock_request")
I think it is this one instead:
591c0fb85d1c ("drm/i915: Exercise request cancellation using a mock selftest")
Fix looks correct so:
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Thanks for the patch!
Regards,
Tvrtko
P.S.
Although Fixes: is probably a bit over the top since it is selftests only so I'll probably drop it while applying.
> Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
> ---
> drivers/gpu/drm/i915/selftests/i915_request.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/selftests/i915_request.c b/drivers/gpu/drm/i915/selftests/i915_request.c
> index d67710d10615..d6fc7b892793 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_request.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_request.c
> @@ -209,6 +209,10 @@ static int igt_request_rewind(void *arg)
> int err = -EINVAL;
>
> ctx[0] = mock_context(i915, "A");
> + if (!ctx[0]) {
> + err = -ENOMEM;
> + goto err_ctx_0;
> + }
>
> ce = i915_gem_context_get_engine(ctx[0], RCS0);
> GEM_BUG_ON(IS_ERR(ce));
> @@ -223,6 +227,10 @@ static int igt_request_rewind(void *arg)
> i915_request_add(request);
>
> ctx[1] = mock_context(i915, "B");
> + if (!ctx[1]) {
> + err = -ENOMEM;
> + goto err_ctx_1;
> + }
>
> ce = i915_gem_context_get_engine(ctx[1], RCS0);
> GEM_BUG_ON(IS_ERR(ce));
> @@ -261,9 +269,11 @@ static int igt_request_rewind(void *arg)
> i915_request_put(vip);
> err_context_1:
> mock_context_close(ctx[1]);
> +err_ctx_1:
> i915_request_put(request);
> err_context_0:
> mock_context_close(ctx[0]);
> +err_ctx_0:
> mock_device_flush(i915);
> return err;
> }
>
prev parent reply other threads:[~2021-11-30 15:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-30 14:15 Zhou Qingyang
2021-11-30 14:58 ` Tvrtko Ursulin [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=a5f5c675-0a7a-8049-d9d6-185cf4f2d91b@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=airlied@linux.ie \
--cc=chengzhihao1@huawei.com \
--cc=chris@chris-wilson.co.uk \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=matthew.auld@intel.com \
--cc=zhou1615@umn.edu \
/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
all inboxes | Powered by JetHome®