[Intel-gfx] [PATCH] drm/i915/query: Split out query item checks

Chris Wilson chris at chris-wilson.co.uk
Wed Jan 9 09:35:33 UTC 2019


Quoting Tvrtko Ursulin (2019-01-09 09:25:49)
> 
> On 09/01/2019 07:51, Abdiel Janulgue wrote:
> > This simplifies adding new query item objects.
> > 
> > Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
> > Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> > ---
> >   drivers/gpu/drm/i915/i915_query.c | 40 ++++++++++++++++++++-----------
> >   1 file changed, 26 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_query.c b/drivers/gpu/drm/i915/i915_query.c
> > index cbcb957b7141..b4f26605f617 100644
> > --- a/drivers/gpu/drm/i915/i915_query.c
> > +++ b/drivers/gpu/drm/i915/i915_query.c
> > @@ -10,12 +10,33 @@
> >   #include "i915_query.h"
> >   #include <uapi/drm/i915_drm.h>
> >   
> > +static int init_query_item_check(void* data_ptr, size_t data_sz,
> 
> void *ptr
> 
> data_ prefix is not ideal since this is not the trailing data but the 
> query header. Maybe query_ ?

Maybe query_hdr, query_pkt?
Or hdr, pkt?

> > +                              u32 total_length,
> > +                              struct drm_i915_query_item *query_item)
> > +{
> > +     if (query_item->length == 0)
> > +             return total_length;
> > +
> > +     if (query_item->length < total_length)
> > +             return -EINVAL;
> > +
> > +     if (copy_from_user(data_ptr, u64_to_user_ptr(query_item->data_ptr),
> > +                        data_sz))
> > +             return -EFAULT;
> 
> Is lost type information a concern with copy_from_user.. let me check.. 
> I am not sure TBH.. there seems to be type based object size check in 
> there but does it work when indirected via void*?

iirc void* is fine, just loss of fancy static checking.
-Chris


More information about the Intel-gfx mailing list