From: Jani Nikula <jani.nikula@linux.intel.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
"Pallavi Mishra" <pallavi.mishra@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH] drm/i915: Fix possible null ptr dereferences
Date: Thu, 09 Dec 2021 15:25:35 +0200 [thread overview]
Message-ID: <87wnkd3o6o.fsf@intel.com> (raw)
In-Reply-To: <38d8d4458215227dcf2983f1cdc920c7771c9108.camel@linux.intel.com>
On Fri, 03 Dec 2021, Thomas Hellström <thomas.hellstrom@linux.intel.com> wrote:
> On Fri, 2021-12-03 at 13:02 +0200, Ville Syrjälä wrote:
>> On Fri, Dec 03, 2021 at 12:02:57PM +0530, Pallavi Mishra wrote:
>> > add null ptr checks to prevent crash/exceptions.
>>
>> BUG_ON()s aren't going to fix anything.
>>
>> > Signed-off-by: Pallavi Mishra <pallavi.mishra@intel.com>
>
> Pallavi,
>
> The NULL pointer dereferences here are probably all false positives
> from a static analyzer. However the GEM_BUG_ONs are fine to assert that
> the assumption really holds and to clearly point out what's going wrong
> if they are hit in CI tests.
I think we're massively overusing GEM_BUG_ON() all over the place.
BR,
Jani.
>
> But the commit message must reflect that.
>
> /Thomas.
>
>
>> > ---
>> > drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 3 +++
>> > drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 3 ++-
>> > 2 files changed, 5 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>> > b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>> > index 218a9b3037c7..997fe73c205b 100644
>> > --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
>> > @@ -906,6 +906,8 @@ vm_access_ttm(struct vm_area_struct *area,
>> > unsigned long addr,
>> > struct drm_i915_gem_object *obj =
>> > i915_ttm_to_gem(area->vm_private_data);
>> >
>> > + GEM_BUG_ON(!obj);
>> > +
>> > if (i915_gem_object_is_readonly(obj) && write)
>> > return -EACCES;
>> >
>> > @@ -966,6 +968,7 @@ static const struct drm_i915_gem_object_ops
>> > i915_gem_ttm_obj_ops = {
>> > void i915_ttm_bo_destroy(struct ttm_buffer_object *bo)
>> > {
>> > struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
>> > + GEM_BUG_ON(!obj);
>> >
>> > i915_gem_object_release_memory_region(obj);
>> > mutex_destroy(&obj->ttm.get_io_page.lock);
>> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
>> > b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
>> > index 80df9f592407..2b684903a9f5 100644
>> > --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
>> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
>> > @@ -371,6 +371,7 @@ int i915_ttm_move_notify(struct
>> > ttm_buffer_object *bo)
>> > struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
>> > int ret;
>> >
>> > + GEM_BUG_ON(!obj);
>> > ret = i915_gem_object_unbind(obj,
>> > I915_GEM_OBJECT_UNBIND_ACTIVE);
>> > if (ret)
>> > return ret;
>> > @@ -506,7 +507,7 @@ static void i915_ttm_memcpy_init(struct
>> > i915_ttm_memcpy_arg *arg,
>> >
>> > dst_reg = i915_ttm_region(bo->bdev, dst_mem->mem_type);
>> > src_reg = i915_ttm_region(bo->bdev, bo->resource-
>> > >mem_type);
>> > - GEM_BUG_ON(!dst_reg || !src_reg);
>> > + GEM_BUG_ON(!dst_reg || !src_reg || !obj);
>> >
>> > arg->dst_iter = !i915_ttm_cpu_maps_iomem(dst_mem) ?
>> > ttm_kmap_iter_tt_init(&arg->_dst_iter.tt, dst_ttm)
>> > :
>> > --
>> > 2.25.1
>>
>
>
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2021-12-09 17:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-03 6:32 [Intel-gfx] [PATCH] drm/i915: Fix possible null ptr dereferences Pallavi Mishra
2021-12-03 8:20 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Fix possible null ptr dereferences (rev2) Patchwork
2021-12-03 10:58 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2021-12-03 11:02 ` [Intel-gfx] [PATCH] drm/i915: Fix possible null ptr dereferences Ville Syrjälä
2021-12-03 11:07 ` Thomas Hellström
2021-12-09 13:25 ` Jani Nikula [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-12-02 11:28 Pallavi Mishra
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=87wnkd3o6o.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=pallavi.mishra@intel.com \
--cc=thomas.hellstrom@linux.intel.com \
--cc=ville.syrjala@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