[Intel-gfx] [PATCH] drm/i915: Avoid the size check WARN in GEM create/userptr IOCTLs

Imre Deak imre.deak at intel.com
Fri Mar 26 21:56:29 UTC 2021


Since
commit ae2fb480f32f ("drm/i915/gem: consolidate 2big error checking for object sizes")
the
	i915_gem_userptr_ioctl()
	i915_gem_create_ioctl()
	i915_gem_dumb_create()
IOCTLs will throw a WARN if the size passed in by userspace is too big.

This keeps now all the SKLs in CI in a tainted state, so avoid the WARN
in these functions to get the machines back online.

Testcase: igt/gem_create/create-massive
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld at intel.com>
Signed-off-by: Imre Deak <imre.deak at intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_create.c  |  3 +++
 drivers/gpu/drm/i915/gem/i915_gem_object.h  | 14 ++++++++++++--
 drivers/gpu/drm/i915/gem/i915_gem_userptr.c |  2 +-
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_create.c b/drivers/gpu/drm/i915/gem/i915_gem_create.c
index 45d60e3d98e3b..a8ce8aa1d50fb 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_create.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_create.c
@@ -27,6 +27,9 @@ i915_gem_create(struct drm_file *file,
 	/* For most of the ABI (e.g. mmap) we think in system pages */
 	GEM_BUG_ON(!IS_ALIGNED(size, PAGE_SIZE));
 
+	if (i915_gem_object_size_2big_nowarn(size))
+		return -E2BIG;
+
 	/* Allocate the new object */
 	obj = i915_gem_object_create_region(mr, size, 0);
 	if (IS_ERR(obj))
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.h b/drivers/gpu/drm/i915/gem/i915_gem_object.h
index 2ebd79537aea9..b06d1eef7a727 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.h
@@ -27,9 +27,9 @@
  * - get_user_pages*() mixed ints with longs
  */
 #define GEM_CHECK_SIZE_OVERFLOW(sz) \
-	GEM_WARN_ON((sz) >> PAGE_SHIFT > INT_MAX)
+	((sz) >> PAGE_SHIFT > INT_MAX)
 
-static inline bool i915_gem_object_size_2big(u64 size)
+static inline bool __i915_gem_object_size_2big(u64 size)
 {
 	struct drm_i915_gem_object *obj;
 
@@ -42,6 +42,16 @@ static inline bool i915_gem_object_size_2big(u64 size)
 	return false;
 }
 
+static inline bool i915_gem_object_size_2big(u64 size)
+{
+	return GEM_WARN_ON(__i915_gem_object_size_2big(size));
+}
+
+static inline bool i915_gem_object_size_2big_nowarn(u64 size)
+{
+	return __i915_gem_object_size_2big(size);
+}
+
 void i915_gem_init__objects(struct drm_i915_private *i915);
 
 struct drm_i915_gem_object *i915_gem_object_alloc(void);
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
index a657b99ec7606..947efcca85ad2 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
@@ -508,7 +508,7 @@ i915_gem_userptr_ioctl(struct drm_device *dev,
 			    I915_USERPTR_UNSYNCHRONIZED))
 		return -EINVAL;
 
-	if (i915_gem_object_size_2big(args->user_size))
+	if (i915_gem_object_size_2big_nowarn(args->user_size))
 		return -E2BIG;
 
 	if (!args->user_size)
-- 
2.25.1



More information about the Intel-gfx mailing list