drm/i915: properly sanity check batch_start_offset
Subsystems (2)
PATCH v2 1/1 drm/i915: properly sanity check batch_start_offset
Check the edge case where batch_start_offset sits exactly on the batch size.
v2: add new range_overflows variant to capture the special case where the size is permitted to be zero, like with batch_len.
Testcase: igt/gem_exec_params/invalid-batch-start-offset
--- drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 6 +++--- drivers/gpu/drm/i915/i915_utils.h | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +3 -3
@@ -2714,9 +2714,9 @@ i915_gem_do_execbuffer(struct drm_device *dev, goto err_vma; } -if (range_overflows_t (u64, - eb.batch_start_offset, eb.batch_len, - eb.batch->vma->size)) { +if (range_overflows_end_t (u64, + eb.batch_start_offset, eb.batch_len, + eb.batch->vma->size)) {drm_dbg (&i915->drm,"Attempting to use out-of-bounds batch\n" ); err = -EINVAL ; goto err_vma;
drivers/gpu/drm/i915/i915_utils.h +12 -0
@@ -108,6 +108,18 @@ bool i915_error_injected(void);#define range_overflows_t (type, start, size, max) \ range_overflows((type)(start), (type)(size), (type)(max)) +#define range_overflows_end (start, size, max) ({ \ + typeof(start) start__ = (start); \ + typeof(size) size__ = (size); \ + typeof(max) max__ = (max); \ + (void)(&start__ == &size__); \ + (void)(&start__ == &max__); \ + start__ >= max__ || size__ > max__ - start__; \ +}) + +#define range_overflows_end_t (type, start, size, max) \ + range_overflows_end((type)(start), (type)(size), (type)(max)) +/* Note we don't consider signbits :| */ #define overflows_type (x,T ) \ (sizeof(x) > sizeof(T) && (x) >> BITS_PER_TYPE(T))
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.DOCS: warning for drm/i915: properly sanity check batch_start_offset (rev2)
== Series Details ==
== Series Details ==
Series: drm/i915: properly sanity check batch_start_offset (rev2)
URL : https://patchwork.freedesktop.org/series/74287/
State : warning
== Summary ==
$ make htmldocs 2>&1 > /dev/null | grep i915 ./drivers/gpu/drm/i915/display/intel_dpll_mgr.h:285: warning: Function parameter or member 'get_freq' not described in 'intel_shared_dpll_funcs'
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: properly sanity check batch_start_offset (rev2)
In reply to Matthew Auld== Series Details ==
== Series Details ==
Series: drm/i915: properly sanity check batch_start_offset (rev2)
URL : https://patchwork.freedesktop.org/series/74287/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_8073 -> Patchwork_16847
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16847/index.html
Known issues
------------
Here are the changes found in Patchwork_16847 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_selftest@live@gem_contexts:
- fi-cfl-guc: [PASS][1] -> [DMESG-FAIL][2] ([i915#943])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8073/fi-cfl-guc/igt@i915_selftest@live@gem_contexts.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16847/fi-cfl-guc/igt@i915_selftest@live@gem_contexts.html
* igt@kms_addfb_basic@addfb25-x-tiled-mismatch:
- fi-tgl-y: [PASS][3] -> [DMESG-WARN][4] ([CI#94] / [i915#402])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8073/fi-tgl-y/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16847/fi-tgl-y/igt@[email protected]
* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: [PASS][5] -> [FAIL][6] ([fdo#111407])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8073/fi-kbl-7500u/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16847/fi-kbl-7500u/igt@[email protected]
#### Possible fixes ####
* igt@vgem_basic@create:
- fi-tgl-y: [DMESG-WARN][7] ([CI#94] / [i915#402]) -> [PASS][8] +1 similar issue
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8073/fi-tgl-y/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16847/fi-tgl-y/igt@[email protected]
[CI#94]: https://gitlab.freedesktop.org/gfx-ci/i915-infra/issues/94
[fdo#111407]: https://bugs.freedesktop.org/show_bug.cgi?id=111407
[i915#402]: https://gitlab.freedesktop.org/drm/intel/issues/402
[i915#943]: https://gitlab.freedesktop.org/drm/intel/issues/943
Participating hosts (47 -> 41)
------------------------------
Additional (4): fi-kbl-soraka fi-elk-e7500 fi-snb-2520m fi-skl-6600u
Missing (10): fi-hsw-4200u fi-hsw-peppy fi-skl-6770hq fi-bsw-cyan fi-bwr-2160 fi-ctg-p8600 fi-skl-lmem fi-kbl-7560u fi-byt-clapper fi-bdw-samus
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_8073 -> Patchwork_16847
CI-20190529: 20190529
CI_DRM_8073: 04042aee59126471bb37cec526ccaf44b4e8d506 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5495: 22df72de8affcec22d9f354bb6148d77f60cc580 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_16847: 5aaff43297e17fe8352c34908a197798c8d66949 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
5aaff43297e1 drm/i915: properly sanity check batch_start_offset
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16847/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: properly sanity check batch_start_offset (rev2)
Quoting Patchwork (2020-03-06 04:28:26)
Quoted 5 lines
== Series Details ==
Series: drm/i915: properly sanity check
batch_start_offset(rev2)
URL : https://patchwork.freedesktop.org/series/74287/
State : success
Apologies, SPF vs intel.com again.
So, I think the _end variant should be for the inclusive endpoint which is the less common form (there's only 3 where we use U32_MAX and the other 24 all use size or total, i.e. exclusive).
So I would convert those 3 to use _end or _excl, and convert the main overflow check to use >=
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx