Re: [Intel-gfx] [PATCH v13 5/9] drm/i915: Check for integer truncation on scatterlist creation

2022-10-07 Thread Gwan-gyeong Mun
On 9/28/22 8:09 PM, Linus Torvalds wrote: On Wed, Sep 28, 2022 at 1:15 AM Gwan-gyeong Mun wrote: + if (check_assign(obj->base.size >> PAGE_SHIFT, &npages)) + return -E2BIG; I have to say, I find that new "check_assign()" macro use to be disgusting. It's one thing to c

Re: [Intel-gfx] [PATCH v13 5/9] drm/i915: Check for integer truncation on scatterlist creation

2022-10-07 Thread Gwan-gyeong Mun
Linus and Kees, I also understood that I should not make and use the macro that performs assignment and checking at the same time, and I will drop it and update it. Kees, the overflows_type() macro had several updates as input from you and the community, and there is an advantage when moving t

Re: [Intel-gfx] [PATCH v13 5/9] drm/i915: Check for integer truncation on scatterlist creation

2022-10-07 Thread Gwan-gyeong Mun
On 9/28/22 11:51 AM, Jani Nikula wrote: On Wed, 28 Sep 2022, Gwan-gyeong Mun wrote: diff --git a/drivers/gpu/drm/i915/i915_scatterlist.h b/drivers/gpu/drm/i915/i915_scatterlist.h index 9ddb3e743a3e..1d1802beb42b 100644 --- a/drivers/gpu/drm/i915/i915_scatterlist.h +++ b/drivers/gpu/drm/i915

Re: [Intel-gfx] [PATCH v13 5/9] drm/i915: Check for integer truncation on scatterlist creation

2022-09-28 Thread Kees Cook
On Wed, Sep 28, 2022 at 10:09:04AM -0700, Linus Torvalds wrote: > Kees, you need to reign in the craziness in overflow.h. Understood. I've been trying to help the drm folks walk a line between having a bunch of custom macros hidden away in the drm includes and building up generalized versions that

Re: [Intel-gfx] [PATCH v13 5/9] drm/i915: Check for integer truncation on scatterlist creation

2022-09-28 Thread Linus Torvalds
On Wed, Sep 28, 2022 at 1:15 AM Gwan-gyeong Mun wrote: > > + if (check_assign(obj->base.size >> PAGE_SHIFT, &npages)) > + return -E2BIG; I have to say, I find that new "check_assign()" macro use to be disgusting. It's one thing to check for overflows. It's another thing enti

Re: [Intel-gfx] [PATCH v13 5/9] drm/i915: Check for integer truncation on scatterlist creation

2022-09-28 Thread Jani Nikula
On Wed, 28 Sep 2022, Gwan-gyeong Mun wrote: > diff --git a/drivers/gpu/drm/i915/i915_scatterlist.h > b/drivers/gpu/drm/i915/i915_scatterlist.h > index 9ddb3e743a3e..1d1802beb42b 100644 > --- a/drivers/gpu/drm/i915/i915_scatterlist.h > +++ b/drivers/gpu/drm/i915/i915_scatterlist.h > @@ -220,4 +220

[Intel-gfx] [PATCH v13 5/9] drm/i915: Check for integer truncation on scatterlist creation

2022-09-28 Thread Gwan-gyeong Mun
From: Chris Wilson There is an impedance mismatch between the scatterlist API using unsigned int and our memory/page accounting in unsigned long. That is we may try to create a scatterlist for a large object that overflows returning a small table into which we try to fit very many pages. As the o