drm/i915: add sanity check for partial view creation
Subsystems (2)
PATCH 1/1 drm/i915: add sanity check for partial view creation
When binding pages for a partial view we should check that the offset + size is valid relative to the size of the gem object.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/i915_gem_gtt.c +4 -0
@@ -3500,6 +3500,10 @@ intel_partial_pages(const struct i915_ggtt_view *view,struct sg_page_iter obj_sg_iter;int ret = -ENOMEM ; +if (view->params.partial.offset + view->params.partial.size > + obj->pages->nents) +return ERR_PTR (-EINVAL ); + st =kmalloc (sizeof (*st),GFP_KERNEL );if (!st) goto err_st_alloc;
Signature · 6 lines
2.4.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: warning for drm/i915: add sanity check for partial view creation
== Series Details ==
== Series Details ==
Series: drm/i915: add sanity check for partial view creation
URL : https://patchwork.freedesktop.org/series/3926/
State : warning
== Summary ==
Series 3926v1 drm/i915: add sanity check for partial view creation
http://patchwork.freedesktop.org/api/1.0/series/3926/revisions/1/mbox/
Test kms_flip:
Subgroup basic-flip-vs-dpms:
pass -> DMESG-WARN (hsw-brixbox)
Subgroup basic-flip-vs-wf_vblank:
dmesg-warn -> PASS (hsw-brixbox)
Test kms_pipe_crc_basic:
Subgroup nonblocking-crc-pipe-b:
dmesg-warn -> PASS (snb-x220t)
Subgroup read-crc-pipe-b:
pass -> DMESG-WARN (hsw-gt2)
Subgroup suspend-read-crc-pipe-c:
pass -> DMESG-WARN (bsw-nuc-2)
Test pm_rpm:
Subgroup basic-pci-d3-state:
fail -> DMESG-FAIL (snb-x220t)
pass -> DMESG-WARN (hsw-gt2)
dmesg-warn -> PASS (byt-nuc)bdw-nuci7 total:166 pass:155 dwarn:0 dfail:0 fail:0 skip:11 bdw-ultra total:169 pass:155 dwarn:0 dfail:0 fail:0 skip:14 bsw-nuc-2 total:169 pass:137 dwarn:1 dfail:0 fail:1 skip:30 byt-nuc total:169 pass:144 dwarn:0 dfail:0 fail:0 skip:25 hsw-brixbox total:169 pass:153 dwarn:1 dfail:0 fail:0 skip:15 hsw-gt2 total:169 pass:156 dwarn:2 dfail:1 fail:0 skip:10 ilk-hp8440p total:169 pass:118 dwarn:0 dfail:0 fail:1 skip:50 ivb-t430s total:169 pass:153 dwarn:0 dfail:0 fail:1 skip:15 snb-dellxps total:169 pass:143 dwarn:2 dfail:0 fail:1 skip:23 snb-x220t total:169 pass:144 dwarn:1 dfail:1 fail:1 skip:22
Results at /archive/results/CI_IGT_test/Patchwork_1495/
a1c053436ca45c5860f842e294ad29d6055bd43b drm-intel-nightly: 2016y-02m-29d-16h-58m-26s UTC integration manifest 2cdbd535042074b7b79b7db1ae18cb632ffd823c drm/i915: add sanity check for partial view creation
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 14 lines · Matthew Auld
When binding pages for a partial view we should check that the offset + size is valid relative to the size of the gem object.
Cc Joonas Lahtinen <[email protected]>Signed-off-by Matthew Auld <[email protected]>--- drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0
drivers/gpu/drm/i915/i915_gem_gtt.c intel_partial_pages(const struct i915_ggtt_view *view, · line 3505
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +3
-0@@ -3500,6 +3500,10 @@ intel_partial_pages(const struct i915_ggtt_view *view,struct sg_page_iter obj_sg_iter;int ret = -ENOMEM ; +if (view->params.partial.offset + view->params.partial.size > + obj->pages->nents) +return ERR_PTR (-EINVAL );
It seems to me that if we hit this, there must a bug somewhere higher up.
Quoted 11 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +1
-0+ st =kmalloc (sizeof (*st),GFP_KERNEL );if (!st) goto err_st_alloc;Signature · 6 lines
2.4.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 4 lines · Matthew Auld
When binding pages for a partial view we should check that the offset + size is valid relative to the size of the gem object.
Cc Joonas Lahtinen <[email protected]>
Quoted 20 lines
Signed-off-by Matthew Auld <[email protected]>---
drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++++1 file changed, 4 insertions(+)drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0@@ -3500,6 +3500,10 @@ intel_partial_pages(const struct i915_ggtt_view *view, struct sg_page_iter obj_sg_iter; int ret = -ENOMEM;drivers/gpu/drm/i915/i915_gem_gtt.c +4
-0+if (view->params.partial.offset + view->params.partial.size > + obj->pages->nents) +return ERR_PTR (-EINVAL ); +st =
kmalloc(sizeof(*st), GFP_KERNEL);
if (!st)
gotoerr_st_alloc;
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 14 lines · Matthew Auld
When binding pages for a partial view we should check that the offset + size is valid relative to the size of the gem object.
Cc Joonas Lahtinen <[email protected]>Signed-off-by Matthew Auld <[email protected]>--- drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0
drivers/gpu/drm/i915/i915_gem_gtt.c intel_partial_pages(const struct i915_ggtt_view *view, · line 3506
Quoted 7 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +4
-0@@ -3500,6 +3500,10 @@ intel_partial_pages(const struct i915_ggtt_view *view,struct sg_page_iter obj_sg_iter;int ret = -ENOMEM ; +if (view->params.partial.offset + view->params.partial.size > + obj->pages->nents) +return ERR_PTR (-EINVAL ); +
obj->pages->nents is not guaranteed to be equal to number of pages but can be less than due sg entry coalescing.
I suggest replacing with a check against "obj->base.size >> PAGE_SHIFT".
drivers/gpu/drm/i915/i915_gem_gtt.c intel_partial_pages(const struct i915_ggtt_view *view, · line 3509
Quoted 4 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0st =kmalloc (sizeof (*st),GFP_KERNEL );if (!st) goto err_st_alloc;
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 13 lines · Joonas Lahtinen
Quoted 4 lines · Matthew Auld
When binding pages for a partial view we should check that the offset + size is valid relative to the size of the gem object.
Cc Joonas Lahtinen <[email protected]>Reviewed-by Joonas Lahtinen <[email protected]>Quoted 5 lines
Signed-off-by Matthew Auld <[email protected]>---
drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++++1 file changed, 4 insertions(+)
Quoted 11 lines
drivers/gpu/drm/i915/i915_gem_gtt.c intel_partial_pages(const struct i915_ggtt_view *view, · line 3505
Quoted 11 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0@@ -3500,6 +3500,10 @@ intel_partial_pages(const struct i915_ggtt_view *view, struct sg_page_iter obj_sg_iter; int ret = -ENOMEM;drivers/gpu/drm/i915/i915_gem_gtt.c +3
-0+if (view->params.partial.offset + view->params.partial.size > + obj->pages->nents) +return ERR_PTR (-EINVAL );
Wrong. Tell me again what nents has to do with the object size? -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerQuoted 11 lines · Ville Syrjälä
Quoted 10 lines · Matthew Auld
When binding pages for a partial view we should check that the offset + size is valid relative to the size of the gem object.
Cc Joonas Lahtinen <[email protected]>Signed-off-by Matthew Auld <[email protected]>---
drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++++1 file changed, 4 insertions(+)
Quoted 14 lines
drivers/gpu/drm/i915/i915_gem_gtt.c intel_partial_pages(const struct i915_ggtt_view *view, · line 3505
Quoted 11 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0@@ -3500,6 +3500,10 @@ intel_partial_pages(const struct i915_ggtt_view *view, struct sg_page_iter obj_sg_iter; int ret = -ENOMEM;drivers/gpu/drm/i915/i915_gem_gtt.c +3
-0+if (view->params.partial.offset + view->params.partial.size > + obj->pages->nents) +return ERR_PTR (-EINVAL );It seems to me that if we hit this, there must a bug somewhere higher up.
Currently yes. This is in preparation of the more widespread support for partial views and was chosen as a good get-to-know-GEM-code candidate.
Regards, Joonas
Quoted 12 lines
Quoted 12 lines
+
st =kmalloc(sizeof(*st), GFP_KERNEL);
if (!st)
gotoerr_st_alloc;
--
2.4.3_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx