drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
Subsystems (2)
PATCH 1/1 drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
From: Ville Syrjälä <[email protected]>
If we have framebuffers that are >= 4GiB in size we will overflow the fb size check in intel_fill_fb_info().
Currently that is only possible with NV12 and CCS as offsets[1] may be anything between 0 and 0xffffffff. ofsets[0] is currently required to be 0 so we can't hit the overflow with any single plane format (thanks to max fb size of 8kx8k and max stride of 32 KiB).
In the future we may allow almost any framebuffer to exceed 4GiB in size so we really should fix the overflow. Not that the overflow is particularly dangerous. It's mostly just a sanity check against insane userspace. The display engine can't write to memory anyway so I suppose in the worst case we might anger the hw by attempting scanout past the end of the ggtt, or we might scan out some data that we're not supposed to see from other parts of the ggtt.
Note that triggering this overflow depends on the driver aligning the fb height to the next tile boundary to push the calculated size above 4GiB. With linear buffers the effective tile height is one so that never happens, and the core already has a check for 32bit overflow of offsets[]+pitches[]*height.
Testcase: igt/kms_big_fb/x-tiled-addfb-size-offset-overflow
Testcase: igt/kms_big_fb/y-tiled-addfb-size-offset-overflow
--- drivers/gpu/drm/i915/intel_display.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +4 -3
@@ -2636,9 +2636,10 @@ intel_fill_fb_info(struct drm_i915_private *dev_priv, max_size =max (max_size, offset + size); } -if (max_size * tile_size > obj->base.size) { -DRM_DEBUG_KMS ("fb too big for bo (need %u bytes, have %zu bytes)\n" , - max_size * tile_size, obj->base.size); +if (mul_u32_u32 (max_size, tile_size) > obj->base.size) { +DRM_DEBUG_KMS ("fb too big for bo (need %llu bytes, have %zu bytes)\n" , + (unsigned long long )mul_u32_u32 (max_size, tile_size), + obj->base.size);return -EINVAL ; }
Signature · 6 lines
2.16.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
== Series Details ==
== Series Details ==
Series: drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
URL : https://patchwork.freedesktop.org/series/49495/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 2eb7a1527556 drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB -:50: CHECK:SPACING: No space is necessary after a cast #50: FILE: drivers/gpu/drm/i915/intel_display.c:2641: + (unsigned long long) mul_u32_u32(max_size, tile_size),
total: 0 errors, 0 warnings, 1 checks, 13 lines checked
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.SPARSE: warning for drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
URL : https://patchwork.freedesktop.org/series/49495/
State : warning
== Summary ==
$ dim sparse origin/drm-tip Commit: drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB -O:drivers/gpu/drm/i915/intel_display.c:2636:28: warning: expression using sizeof(void) -O:drivers/gpu/drm/i915/intel_display.c:2636:28: warning: expression using sizeof(void) +drivers/gpu/drm/i915/intel_display.c:2636:28: warning: expression using sizeof(void) +drivers/gpu/drm/i915/intel_display.c:2636:28: warning: expression using sizeof(void)
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
URL : https://patchwork.freedesktop.org/series/49495/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4801 -> Patchwork_10144 =
== Summary - SUCCESS ==
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/49495/revisions/1/mbox/
== Known issues ==
Here are the changes found in Patchwork_10144 that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@amdgpu/amd_basic@userptr:
fi-kbl-8809g: PASS -> INCOMPLETE (fdo#107402)
igt@drv_selftest@live_guc:
fi-skl-guc: NOTRUN -> DMESG-WARN (fdo#107258)
==== Possible fixes ====
igt@kms_pipe_crc_basic@read-crc-pipe-a:
fi-byt-clapper: FAIL (fdo#107362) -> PASS
igt@kms_psr@primary_page_flip:
fi-kbl-7560u: FAIL (fdo#107336) -> PASS
igt@prime_vgem@basic-fence-flip:
fi-ilk-650: FAIL (fdo#104008) -> PASS fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
fdo#107258 https://bugs.freedesktop.org/show_bug.cgi?id=107258
fdo#107336 https://bugs.freedesktop.org/show_bug.cgi?id=107336
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
fdo#107402 https://bugs.freedesktop.org/show_bug.cgi?id=107402
== Participating hosts (48 -> 43) ==
Additional (1): fi-skl-guc
Missing (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-gdg-551
== Build changes ==
* Linux: CI_DRM_4801 -> Patchwork_10144
CI_DRM_4801: 47eb47da6081c676a6f9e6046db5a72fa7d22ef4 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4638: 20a7ead8bdf09774c7d58fcbe6a0980d08ed5365 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10144: 2eb7a152755603e9a9228c43dce43415e03d4097 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
2eb7a1527556 drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10144/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
URL : https://patchwork.freedesktop.org/series/49495/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4801_full -> Patchwork_10144_full =
== Summary - SUCCESS ==
No regressions found.
== Known issues ==
Here are the changes found in Patchwork_10144_full that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@gem_exec_schedule@pi-ringfull-bsd:
shard-glk: NOTRUN -> FAIL (fdo#103158)
igt@kms_available_modes_crc@available_mode_test_crc:
shard-glk: NOTRUN -> FAIL (fdo#106641)
igt@kms_cursor_crc@cursor-256x85-random:
shard-kbl: PASS -> DMESG-WARN (fdo#105345)
==== Possible fixes ====
igt@gem_eio@in-flight-suspend:
shard-glk: INCOMPLETE (k.org#198133, fdo#103359) -> PASS
igt@kms_setmode@basic:
shard-apl: FAIL (fdo#99912) -> PASS fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158
fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
fdo#105345 https://bugs.freedesktop.org/show_bug.cgi?id=105345
fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133
== Participating hosts (5 -> 5) ==
No changes in participating hosts
== Build changes ==
* Linux: CI_DRM_4801 -> Patchwork_10144
CI_DRM_4801: 47eb47da6081c676a6f9e6046db5a72fa7d22ef4 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4638: 20a7ead8bdf09774c7d58fcbe6a0980d08ed5365 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10144: 2eb7a152755603e9a9228c43dce43415e03d4097 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10144/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Ville Syrjala (2018-09-11 17:54:57)
Quoted 37 lines
From: Ville Syrjälä <[email protected]>
If we have framebuffers that are >= 4GiB in size we will overflow the fb size check in
intel_fill_fb_info().Currently that is only possible with NV12 and CCS as offsets[1] may be anything between 0 and
0xffffffff. ofsets[0] is currently required to be 0 so we can't hit the overflow with any single plane format (thanks to max fb size of 8kx8k and max stride of 32 KiB).In the future we may allow almost any framebuffer to exceed 4GiB in size so we really should fix the overflow. Not that the overflow is particularly dangerous. It's mostly just a sanity check against insane userspace. The display engine can't write to memory anyway so I suppose in the worst case we might anger the hw by attempting scanout past the end of the ggtt, or we might scan out some data that we're not supposed to see from other parts of the ggtt.
Note that triggering this overflow depends on the driver aligning the fb height to the next tile boundary to push the calculated size above 4GiB. With linear buffers the effective tile height is one so that never happens, and the core already has a check for 32bit overflow of offsets[]+pitches[]*height.
Testcase: igt/kms_big_fb/x-tiled-addfb-size-offset-overflow
Testcase: igt/kms_big_fb/y-tiled-addfb-size-offset-overflowSigned-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/intel_display.c +0
-0
drivers/gpu/drm/i915/intel_display.c intel_fill_fb_info(struct drm_i915_private *dev_priv, · line 2641
Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +3
-3@@ -2636,9 +2636,10 @@ intel_fill_fb_info(struct drm_i915_private *dev_priv, max_size =max (max_size, offset + size); } -if (max_size * tile_size > obj->base.size) { -DRM_DEBUG_KMS ("fb too big for bo (need %u bytes, have %zu bytes)\n" , - max_size * tile_size, obj->base.size); +if (mul_u32_u32 (max_size, tile_size) > obj->base.size) { + DRM_DEBUG_KMS("fb too big for bo (need %llu bytes, have %zu bytes)\n", + (unsigned long long) mul_u32_u32(max_size, tile_size),
mul_u32_u32 returns u64 i.e. unsigned long long; %llu is the one true format specifier for u64 (Linus decree #103789)
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 41 lines · Chris Wilson
Quoting Ville Syrjala (2018-09-11 17:54:57)
Quoted 40 lines
From: Ville Syrjälä <[email protected]>
If we have framebuffers that are >= 4GiB in size we will overflow the fb size check in
intel_fill_fb_info().Currently that is only possible with NV12 and CCS as offsets[1] may be anything between 0 and
0xffffffff. ofsets[0] is currently required to be 0 so we can't hit the overflow with any single plane format (thanks to max fb size of 8kx8k and max stride of 32 KiB).In the future we may allow almost any framebuffer to exceed 4GiB in size so we really should fix the overflow. Not that the overflow is particularly dangerous. It's mostly just a sanity check against insane userspace. The display engine can't write to memory anyway so I suppose in the worst case we might anger the hw by attempting scanout past the end of the ggtt, or we might scan out some data that we're not supposed to see from other parts of the ggtt.
Note that triggering this overflow depends on the driver aligning the fb height to the next tile boundary to push the calculated size above 4GiB. With linear buffers the effective tile height is one so that never happens, and the core already has a check for 32bit overflow of offsets[]+pitches[]*height.
Testcase: igt/kms_big_fb/x-tiled-addfb-size-offset-overflow
Testcase: igt/kms_big_fb/y-tiled-addfb-size-offset-overflowSigned-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/intel_display.c +0
-0@@ -2636,9 +2636,10 @@ intel_fill_fb_info(struct drm_i915_private *dev_priv, max_size =max (max_size, offset + size); }
Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c intel_fill_fb_info(struct drm_i915_private *dev_priv, · line 2641
Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +3
-3-if (max_size * tile_size > obj->base.size) { -DRM_DEBUG_KMS ("fb too big for bo (need %u bytes, have %zu bytes)\n" , - max_size * tile_size, obj->base.size); +if (mul_u32_u32 (max_size, tile_size) > obj->base.size) { + DRM_DEBUG_KMS("fb too big for bo (need %llu bytes, have %zu bytes)\n", + (unsigned long long) mul_u32_u32(max_size, tile_size),
mul_u32_u32returns u64 i.e. unsigned long long; %llu is the one true format specifier for u64 (Linus decree #103789)
Well whaddyaknow, so it is. Never realized that for some reason.
Quoted 3 lines
Reviewed-by Chris Wilson <[email protected]>-Chris
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/1 drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
If we have framebuffers that are >= 4GiB in size we will overflow the fb size check in intel_fill_fb_info().
Currently that is only possible with NV12 and CCS as offsets[1] may be anything between 0 and 0xffffffff. offsets[0] is currently required to be 0 so we can't hit the overflow with any single plane format (thanks to max fb size of 8kx8k and max stride of 32 KiB).
In the future we may allow almost any framebuffer to exceed 4GiB in size so we really should fix the overflow. Not that the overflow is particularly dangerous. It's mostly just a sanity check against insane userspace. The display engine can't write to memory anyway so I suppose in the worst case we might anger the hw by attempting scanout past the end of the ggtt, or we might scan out some data that we're not supposed to see from other parts of the ggtt.
Note that triggering this overflow depends on the driver aligning the fb height to the next tile boundary to push the calculated size above 4GiB. With linear buffers the effective tile height is one so that never happens, and the core already has a check for 32bit overflow of offsets[]+pitches[]*height.
v2: Drop the unnecessary cast (Chris)
Testcase: igt/kms_big_fb/x-tiled-addfb-size-offset-overflow
Testcase: igt/kms_big_fb/y-tiled-addfb-size-offset-overflow
--- drivers/gpu/drm/i915/intel_display.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -3
@@ -2640,9 +2640,9 @@ intel_fill_fb_info(struct drm_i915_private *dev_priv, max_size =max (max_size, offset + size); } -if (max_size * tile_size > obj->base.size) { -DRM_DEBUG_KMS ("fb too big for bo (need %u bytes, have %zu bytes)\n" , - max_size * tile_size, obj->base.size); +if (mul_u32_u32 (max_size, tile_size) > obj->base.size) { +DRM_DEBUG_KMS ("fb too big for bo (need %llu bytes, have %zu bytes)\n" , +mul_u32_u32 (max_size, tile_size), obj->base.size);return -EINVAL ; }
Signature · 6 lines
2.16.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.SPARSE: warning for drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB (rev2)
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB (rev2)
URL : https://patchwork.freedesktop.org/series/49495/
State : warning
== Summary ==
$ dim sparse origin/drm-tip Commit: drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB -O:drivers/gpu/drm/i915/intel_display.c:2640:28: warning: expression using sizeof(void) -O:drivers/gpu/drm/i915/intel_display.c:2640:28: warning: expression using sizeof(void) +drivers/gpu/drm/i915/intel_display.c:2640:28: warning: expression using sizeof(void) +drivers/gpu/drm/i915/intel_display.c:2640:28: warning: expression using sizeof(void)
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB (rev2)
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB (rev2)
URL : https://patchwork.freedesktop.org/series/49495/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4813 -> Patchwork_10161 =
== Summary - SUCCESS ==
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/49495/revisions/2/mbox/
== Known issues ==
Here are the changes found in Patchwork_10161 that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@debugfs_test@read_all_entries:
fi-snb-2520m: PASS -> INCOMPLETE (fdo#103713)
igt@kms_pipe_crc_basic@hang-read-crc-pipe-a:
fi-byt-clapper: PASS -> FAIL (fdo#103191, fdo#107362)
igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
fi-bdw-samus: PASS -> INCOMPLETE (fdo#107773)
igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
fi-skl-guc: PASS -> FAIL (fdo#103191)
==== Possible fixes ====
igt@drv_selftest@live_hangcheck:
fi-cfl-guc: DMESG-FAIL (fdo#107710) -> PASS
igt@gem_exec_suspend@basic-s4-devices:
fi-kbl-7500u: DMESG-WARN (fdo#105128, fdo#107139) -> PASS
igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
fi-bxt-dsi: INCOMPLETE (fdo#103927) -> PASS fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fdo#105128 https://bugs.freedesktop.org/show_bug.cgi?id=105128
fdo#107139 https://bugs.freedesktop.org/show_bug.cgi?id=107139
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
fdo#107710 https://bugs.freedesktop.org/show_bug.cgi?id=107710
fdo#107773 https://bugs.freedesktop.org/show_bug.cgi?id=107773
== Participating hosts (51 -> 44) ==
Missing (7): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-icl-u
== Build changes ==
* Linux: CI_DRM_4813 -> Patchwork_10161
CI_DRM_4813: 3c13515b12339366b414637b69227a4e3cbe21ae @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4640: 9a8da36e708f9ed15b20689dfe305e41f9a19008 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10161: 712f10408dd4482a72bf80eebf61d5f63761e8a7 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
712f10408dd4 drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10161/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB (rev2)
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm/i915: Fix a potential integer overflow with framebuffers extending past 4 GiB (rev2)
URL : https://patchwork.freedesktop.org/series/49495/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4813_full -> Patchwork_10161_full =
== Summary - SUCCESS ==
No regressions found.
== Known issues ==
Here are the changes found in Patchwork_10161_full that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@kms_flip@2x-flip-vs-expired-vblank:
shard-glk: PASS -> FAIL (fdo#105363)
==== Possible fixes ====
igt@gem_exec_await@wide-contexts:
shard-glk: FAIL (fdo#106680) -> PASS fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
fdo#106680 https://bugs.freedesktop.org/show_bug.cgi?id=106680
== Participating hosts (5 -> 5) ==
No changes in participating hosts
== Build changes ==
* Linux: CI_DRM_4813 -> Patchwork_10161
CI_DRM_4813: 3c13515b12339366b414637b69227a4e3cbe21ae @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4640: 9a8da36e708f9ed15b20689dfe305e41f9a19008 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10161: 712f10408dd4482a72bf80eebf61d5f63761e8a7 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10161/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx