Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Matthew Auld <matthew.auld@intel.com>,
	Chris Wilson <chris@chris-wilson.co.uk>
Subject: [Intel-gfx] [PATCH] drm/i915: Avoid the size check WARN in GEM create/userptr IOCTLs
Date: Fri, 26 Mar 2021 23:56:29 +0200	[thread overview]
Message-ID: <20210326215629.2423461-1-imre.deak@intel.com> (raw)

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@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Imre Deak <imre.deak@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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2021-03-26 21:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26 21:56 Imre Deak [this message]
2021-03-26 22:44 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Avoid the size check WARN in GEM create/userptr IOCTLs Patchwork
2021-03-26 22:49 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2021-03-26 23:14 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-03-27  1:32 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork

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=20210326215629.2423461-1-imre.deak@intel.com \
    --to=imre.deak@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.auld@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