Skip to contentSkip to conversation

lib/kms: Range check pipe before lookup

PATCH In review Chris Wilson 3 participants 6 messages Nov 19, 2020 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/kms: Range check pipe before lookup

Make sure the lookup index is within the range of the table before accessing.

---
 lib/igt_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/igt_kms.c +1 -1
index e5d8e82c9..9175e50fe 100644
@@ -1902,7 +1902,7 @@ static void igt_fill_display_format_mod(igt_display_t *display);
  */
 void igt_require_pipe(igt_display_t *display, enum pipe pipe)
 {
-	igt_skip_on_f(!display->pipes[pipe].enabled,
+	igt_skip_on_f(pipe >= display->n_pipes || !display->pipes[pipe].enabled,
 			"Pipe %s does not exist or not enabled\n",
 			kmstest_pipe_name(pipe));
 }
Signature · 6 lines
2.29.2

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw
Quoted 13 lines · Chris Wilson

Make sure the lookup index is within the range of the table before accessing.

---
 lib/igt_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/igt_kms.c +0 -0
index e5d8e82c9..9175e50fe 100644

lib/igt_kms.c static void igt_fill_display_format_mod(igt_display_t *display); · line 1907

Quoted 7 lines
lib/igt_kms.c +1 -1
@@ -1902,7 +1902,7 @@ static void igt_fill_display_format_mod(igt_display_t *display);
  */
 void igt_require_pipe(igt_display_t *display, enum pipe pipe)
 {
-	igt_skip_on_f(!display->pipes[pipe].enabled,
+	igt_skip_on_f(pipe >= display->n_pipes || !display->pipes[pipe].enabled,
 			"Pipe %s does not exist or not enabled\n",
 			kmstest_pipe_name(pipe));

Who's calling this with an invalid 'pipe' value? display->pipes size is no longer display->n_pipes, right?

Signature · 5 lines
Petri Latvala
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#2 lore raw
Quoted 9 lines · Petri Latvala
Quoted 8 lines · Chris Wilson

Make sure the lookup index is within the range of the table before accessing.

---
 lib/igt_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

lib/igt_kms.c static void igt_fill_display_format_mod(igt_display_t *display); · line 1907

Quoted 12 lines
lib/igt_kms.c +1 -1
index e5d8e82c9..9175e50fe 100644
@@ -1902,7 +1902,7 @@ static void igt_fill_display_format_mod(igt_display_t *display);
  */
 void igt_require_pipe(igt_display_t *display, enum pipe pipe)
 {
-	igt_skip_on_f(!display->pipes[pipe].enabled,
+	igt_skip_on_f(pipe >= display->n_pipes || !display->pipes[pipe].enabled,
 			"Pipe %s does not exist or not enabled\n",
 			kmstest_pipe_name(pipe));

Who's calling this with an invalid 'pipe' value? display->pipes size is no longer display->n_pipes, right?

Correction, it is. But n_pipes is not the amount of pipes as reported by count_crtcs, it's IGT_MAX_PIPES.

So who's calling this with 'pipe' that's >= IGT_MAX_PIPES?

Signature · 5 lines
Petri Latvala
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#3 lore raw
In reply to Petri Latvala

Quoting Petri Latvala (2020-11-19 08:53:04)

Quoted 9 lines · Chris Wilson
Quoted 8 lines

Make sure the lookup index is within the range of the table before accessing.

---
 lib/igt_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

lib/igt_kms.c static void igt_fill_display_format_mod(igt_display_t *display); · line 1907

Quoted 12 lines
lib/igt_kms.c +1 -1
index e5d8e82c9..9175e50fe 100644
@@ -1902,7 +1902,7 @@ static void igt_fill_display_format_mod(igt_display_t *display);
  */
 void igt_require_pipe(igt_display_t *display, enum pipe pipe)
 {
-     igt_skip_on_f(!display->pipes[pipe].enabled,
+     igt_skip_on_f(pipe >= display->n_pipes || !display->pipes[pipe].enabled,
                      "Pipe %s does not exist or not enabled\n",
                      kmstest_pipe_name(pipe));

Who's calling this with an invalid 'pipe' value? display->pipes size is no longer display->n_pipes, right?

https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9356/shard-skl8/igt@[email protected]
Starting subtest: disable-crc-after-crtc-pipe-B Received signal SIGSEGV.
Stack trace:
#0 [fatal_sig_handler+0xd6]
#1 [killpg+0x40]
#2 [igt_output_get_mode+0x0]
#3 [__real_main261+0x629]
#4 [main+0x27]
#5 [__libc_start_main+0xe7]
#6 [_start+0x2a]
Subtest disable-crc-after-crtc-pipe-B: CRASH (0.087s)

Suggests that the output is NULL/garbage, so I was looking for ideas as to how we end up dying there. The loop in test_read_crc() doesn't look susceptible to corrupting the local variable, so I guess the output was suspect to begin with.
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#4 lore raw
Quoted 39 lines · Chris Wilson

Quoting Petri Latvala (2020-11-19 08:53:04)

Quoted 9 lines · Chris Wilson
Quoted 8 lines

Make sure the lookup index is within the range of the table before accessing.

---
 lib/igt_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

lib/igt_kms.c static void igt_fill_display_format_mod(igt_display_t *display); · line 1907

Quoted 12 lines
lib/igt_kms.c +1 -1
index e5d8e82c9..9175e50fe 100644
@@ -1902,7 +1902,7 @@ static void igt_fill_display_format_mod(igt_display_t *display);
  */
 void igt_require_pipe(igt_display_t *display, enum pipe pipe)
 {
-     igt_skip_on_f(!display->pipes[pipe].enabled,
+     igt_skip_on_f(pipe >= display->n_pipes || !display->pipes[pipe].enabled,
                      "Pipe %s does not exist or not enabled\n",
                      kmstest_pipe_name(pipe));

Who's calling this with an invalid 'pipe' value? display->pipes size is no longer display->n_pipes, right?

https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9356/shard-skl8/igt@[email protected]
Starting subtest: disable-crc-after-crtc-pipe-B Received signal SIGSEGV.
Stack trace:
#0 [fatal_sig_handler+0xd6]
#1 [killpg+0x40]
#2 [igt_output_get_mode+0x0]
#3 [__real_main261+0x629]
#4 [main+0x27]
#5 [__libc_start_main+0xe7]
#6 [_start+0x2a]
Subtest disable-crc-after-crtc-pipe-B: CRASH (0.087s)

Quoted 4 lines

Suggests that the output is NULL/garbage, so I was looking for ideas as to how we end up dying there. The loop in test_read_crc() doesn't look susceptible to corrupting the local variable, so I guess the output was suspect to begin with.

Hmm yeah.

Other tests are explicitly checking that igt_get_single_output_for_pipe returns non-null, that one doesn't...

In fact it doesn't even call igt_require_pipe. Even before the support for fused pipes was merged, that test looks broken.

Signature · 5 lines
Petri Latvala
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#5 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for lib/kms: Range check pipe before lookup

In reply to Chris Wilson
== Series Details ==

== Series Details ==

Series: lib/kms: Range check pipe before lookup
URL : https://patchwork.freedesktop.org/series/84053/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_9359 -> IGTPW_5192
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_5192 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_5192, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/index.html

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in IGTPW_5192:

### IGT changes ###

#### Possible regressions ####

* igt@gem_exec_suspend@basic-s0:
- fi-glk-dsi: NOTRUN -> [INCOMPLETE][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/fi-glk-dsi/igt@[email protected]

Known issues
------------

Here are the changes found in IGTPW_5192 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@core_hotunplug@unbind-rebind:
- fi-skl-6700k2: [PASS][2] -> [DMESG-WARN][3] ([i915#1982])
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9359/fi-skl-6700k2/igt@[email protected]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/fi-skl-6700k2/igt@[email protected]

* igt@i915_module_load@reload:
- fi-icl-y: [PASS][4] -> [DMESG-WARN][5] ([i915#1982])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9359/fi-icl-y/igt@[email protected]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/fi-icl-y/igt@[email protected]

* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-byt-j1900: [PASS][6] -> [DMESG-WARN][7] ([i915#1982])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9359/fi-byt-j1900/igt@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/fi-byt-j1900/igt@[email protected]

* igt@kms_cursor_legacy@basic-flip-after-cursor-atomic:
- fi-icl-u2: [PASS][8] -> [DMESG-WARN][9] ([i915#1982])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9359/fi-icl-u2/igt@[email protected]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/fi-icl-u2/igt@[email protected]

* igt@kms_frontbuffer_tracking@basic:
- fi-tgl-y: [PASS][10] -> [DMESG-WARN][11] ([i915#1982])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9359/fi-tgl-y/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/fi-tgl-y/igt@[email protected]

* igt@prime_vgem@basic-fence-flip:
- fi-tgl-y: [PASS][12] -> [DMESG-WARN][13] ([i915#402]) +1 similar issue
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9359/fi-tgl-y/igt@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/fi-tgl-y/igt@[email protected]

#### Possible fixes ####

* igt@core_hotunplug@unbind-rebind:
- fi-skl-lmem: [DMESG-WARN][14] ([i915#2605]) -> [PASS][15]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9359/fi-skl-lmem/igt@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/fi-skl-lmem/igt@[email protected]
- fi-tgl-u2: [DMESG-WARN][16] ([i915#1982]) -> [PASS][17]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9359/fi-tgl-u2/igt@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/fi-tgl-u2/igt@[email protected]

* igt@gem_sync@basic-each:
- fi-tgl-y: [DMESG-WARN][18] ([i915#402]) -> [PASS][19] +2 similar issues
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9359/fi-tgl-y/igt@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/fi-tgl-y/igt@[email protected]

* igt@i915_selftest@live@gt_pm:
- {fi-kbl-7560u}: [DMESG-FAIL][20] ([i915#2524]) -> [PASS][21]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9359/fi-kbl-7560u/igt@i915_selftest@live@gt_pm.html
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/fi-kbl-7560u/igt@i915_selftest@live@gt_pm.html

* igt@kms_flip@basic-flip-vs-wf_vblank@b-edp1:
- fi-icl-u2: [DMESG-WARN][22] ([i915#1982]) -> [PASS][23]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9359/fi-icl-u2/igt@kms_flip@[email protected]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/fi-icl-u2/igt@kms_flip@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#2524]: https://gitlab.freedesktop.org/drm/intel/issues/2524
[i915#2605]: https://gitlab.freedesktop.org/drm/intel/issues/2605
[i915#402]: https://gitlab.freedesktop.org/drm/intel/issues/402

Participating hosts (40 -> 36)
------------------------------

Additional (1): fi-glk-dsi
Missing (5): fi-ilk-m540 fi-tgl-dsi fi-hsw-4200u fi-bsw-cyan fi-bdw-samus

Build changes
-------------

* CI: CI-20190529 -> None
* IGT: IGT_5858 -> IGTPW_5192

CI-20190529: 20190529
CI_DRM_9359: 5529f30897761dc08c5cfcefc6d1659f9250d622 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_5192: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/index.html
IGT_5858: 300ee395f5c0ed53ab0757d9c5b311f9c1f641c8 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5192/index.html

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev