Skip to contentSkip to conversation

drm/i915: add sanity check for partial view creation

PATCH New Matthew Auld 2 participants 2 messages Mar 18, 2016 – Mar 21, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: add sanity check for partial view creation

Upon creating a partial view we should check that the offset + size is valid relative to the size of the gem object.

v2:
(Tvrtko Ursulin)
- Don't use pages->nents to determine the page count
v3:
(Chris Wilson)
- Handle potential overflow
v4:
(Chris Wilson)
- Idiomatically handle overflow
- Less idiotic placement
- Treat as programmer error

Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/i915/i915_gem_gtt.c +8 -0
index fb0f963..593eb15 100644
@@ -3356,6 +3356,14 @@ i915_gem_obj_lookup_or_create_ggtt_vma(struct drm_i915_gem_object *obj,
 	if (WARN_ON(!view))
 		return ERR_PTR(-EINVAL);
 
+	if (view->type == I915_GGTT_VIEW_PARTIAL) {
+		unsigned int page_count = obj->base.size >> PAGE_SHIFT;
+		if (WARN_ON(view->params.partial.offset > page_count ||
+			    view->params.partial.size > page_count  -
+			    view->params.partial.offset))
+			return ERR_PTR(-EINVAL);
+	}
+
 	vma = i915_gem_obj_to_ggtt_view(obj, view);
 
 	if (IS_ERR(vma))
Signature · 6 lines
2.4.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

✗ Fi.CI.BAT: warning for drm/i915: add sanity check for partial view creation (rev4)

== Series Details ==

== Series Details ==

Series: drm/i915: add sanity check for partial view creation (rev4)
URL : https://patchwork.freedesktop.org/series/3926/
State : warning

== Summary ==

Series 3926v4 drm/i915: add sanity check for partial view creation
http://patchwork.freedesktop.org/api/1.0/series/3926/revisions/4/mbox/

Test gem_ringfill:

        Subgroup basic-default-s3:
                dmesg-warn -> PASS       (bsw-nuc-2)
Test kms_flip:
        Subgroup basic-flip-vs-wf_vblank:
                fail       -> PASS       (byt-nuc)
Test kms_pipe_crc_basic:
        Subgroup nonblocking-crc-pipe-a:
                dmesg-warn -> PASS       (snb-x220t)
        Subgroup suspend-read-crc-pipe-c:
                pass       -> DMESG-WARN (bsw-nuc-2)
                incomplete -> PASS       (hsw-gt2)
Test pm_rpm:
        Subgroup basic-pci-d3-state:
                fail       -> DMESG-FAIL (snb-x220t)
        Subgroup basic-rte:
                pass       -> DMESG-WARN (bsw-nuc-2)
                pass       -> DMESG-WARN (hsw-brixbox)
bdw-nuci7        total:194  pass:182  dwarn:0   dfail:0   fail:0   skip:12 
bdw-ultra        total:194  pass:173  dwarn:0   dfail:0   fail:0   skip:21 
bsw-nuc-2        total:194  pass:155  dwarn:2   dfail:0   fail:0   skip:37 
byt-nuc          total:194  pass:159  dwarn:0   dfail:0   fail:0   skip:35 
hsw-brixbox      total:194  pass:171  dwarn:1   dfail:0   fail:0   skip:22 
hsw-gt2          total:194  pass:176  dwarn:1   dfail:0   fail:0   skip:17 
ilk-hp8440p      total:194  pass:131  dwarn:0   dfail:0   fail:0   skip:63 
ivb-t430s        total:194  pass:169  dwarn:0   dfail:0   fail:0   skip:25 
skl-i7k-2        total:194  pass:171  dwarn:0   dfail:0   fail:0   skip:23 
snb-dellxps      total:194  pass:159  dwarn:1   dfail:0   fail:0   skip:34 
snb-x220t        total:194  pass:160  dwarn:0   dfail:1   fail:0   skip:33 

Results at /archive/results/CI_IGT_test/Patchwork_1647/

e7a7673e9840fe8b50a5a2894c75565ec7858a00 drm-intel-nightly: 2016y-03m-19d-10h-09m-53s UTC integration manifest 43779651b7d362a514463de6b52742d1f09a1d57 drm/i915: add sanity check for partial view creation

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx