[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87edvvzxu3.fsf@intel.com>
Date: Wed, 28 Sep 2022 11:51:00 +0300
From: Jani Nikula <jani.nikula@...el.com>
To: Gwan-gyeong Mun <gwan-gyeong.mun@...el.com>,
intel-gfx@...ts.freedesktop.org
Cc: linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
mchehab@...nel.org, chris@...is-wilson.co.uk,
matthew.auld@...el.com, thomas.hellstrom@...ux.intel.com,
nirmoy.das@...el.com, airlied@...hat.com, daniel@...ll.ch,
andi.shyti@...ux.intel.com, andrzej.hajda@...el.com,
keescook@...omium.org, mauro.chehab@...ux.intel.com,
linux@...musvillemoes.dk, vitor@...saru.org, dlatypov@...gle.com,
ndesaulniers@...gle.com, trix@...hat.com, llvm@...ts.linux.dev,
linux-hardening@...r.kernel.org, linux-sparse@...r.kernel.org,
nathan@...nel.org, gustavoars@...nel.org,
luc.vanoostenryck@...il.com
Subject: Re: [PATCH v13 5/9] drm/i915: Check for integer truncation on
scatterlist creation
On Wed, 28 Sep 2022, Gwan-gyeong Mun <gwan-gyeong.mun@...el.com> 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,15 @@ struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
> u64 region_start,
> u32 page_alignment);
>
> +/* Wrap scatterlist.h to sanity check for integer truncation */
> +typedef unsigned int __sg_size_t; /* see linux/scatterlist.h */
> +#define sg_alloc_table(sgt, nents, gfp) \
> + overflows_type(nents, __sg_size_t) ? -E2BIG \
> + : ((sg_alloc_table)(sgt, (__sg_size_t)(nents), gfp))
> +
> +#define sg_alloc_table_from_pages_segment(sgt, pages, npages, offset, size, max_segment, gfp) \
> + overflows_type(npages, __sg_size_t) ? -E2BIG \
> + : ((sg_alloc_table_from_pages_segment)(sgt, pages, (__sg_size_t)(npages), offset, \
> + size, max_segment, gfp))
> +
> #endif
No. I don't think we should shadow sg_alloc_table() and
sg_alloc_table_from_pages_segment().
Either get this in scatterlist.h (preferred) or prefix with i915_ or
whatever to indicate it's our local thing.
i915_scatterlist.h already has too much scatterlist "namespace" abuse
that I'd rather see gone than violated more.
BR,
Jani.
--
Jani Nikula, Intel Open Source Graphics Center
Powered by blists - more mailing lists