Skip to contentSkip to conversation

Fixed NULL pointer dereference in handle_edid functions for GPUs that do not support EDID

PATCH New Alejandro Sior 2 participants 3 messages Sep 8, 2020

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

PATCH 1/1 Fixed NULL pointer dereference in handle_edid functions for GPUs that do not support EDID

In the function intel_vgpu_reg_rw_edid of gvt/kvmgt.c, pos can get equal to NULL for GPUs that do not properly support EDID. In those cases, when pos gets passed to the handle_edid functions, it gets added a short offset then it's dereferenced in memcpy's, leading to a kernel
oops: null pointer dereference.

More concretely, that kernel oops renders Broadwell GPUs users
completely unable to set up virtual machines with virtual GPU passthrough (virtual machines
hang indefinitely when trying to make use of the virtual GPU), and make
them have huge problems when trying to remove the virtual GPUs once the
kernel oops has happened (writing 1 in the vGPU remove file just makes
the operation hang undefinitely, again, and the kernel is unable to shutdown
since the vGPU removing hangs indefinitely). More information on the
issues that this causes are described in details in this github issue post: https://github.com/intel/gvt-linux/issues/170#issuecomment-685806160

This patch solves this problem by checking is pos is equal to NULL, and
if it is, it sets ret to a nagative value, making the module simply indicate that the access to EDID region has failed, without any fatal repercussion.

When this patch is applied, Broadwell GPU users do not suffer from that kernel oops anymore, and thus do not encounter any of
the described problems and get able to set up virtual machines with GPU passthrough without problems.
Users of GPUs with proper EDID support, are of course, still able to benefit from the EDID features.

---
 drivers/gpu/drm/i915/gvt/kvmgt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gvt/kvmgt.c +3 -1
index ad8a9df49f29..49163363ba4a 100644
@@ -557,7 +557,9 @@ static size_t intel_vgpu_reg_rw_edid(struct intel_vgpu *vgpu, char *buf,
 		(struct vfio_edid_region *)kvmgt_vdev(vgpu)->region[i].data;
 	loff_t pos = *ppos & VFIO_PCI_OFFSET_MASK;
 
-	if (pos < region->vfio_edid_regs.edid_offset) {
+	if (pos == NULL) {
+		ret = -EINVAL;
+	} else if (pos < region->vfio_edid_regs.edid_offset) {
 		ret = handle_edid_regs(vgpu, region, buf, count, pos, iswrite);
 	} else {
 		pos -= EDID_BLOB_OFFSET;
Signature · 1 line
2.28.0
#1 lore raw

[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Fixed NULL pointer dereference in handle_edid functions for GPUs that do not support EDID

== Series Details ==

== Series Details ==

Series: Fixed NULL pointer dereference in handle_edid functions for GPUs that do not support EDID
URL : https://patchwork.freedesktop.org/series/81463/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
24f0f91b0b97 Fixed NULL pointer dereference in handle_edid functions for GPUs that do not support EDID
-:7: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#7: 
In the function intel_vgpu_reg_rw_edid of gvt/kvmgt.c, pos can get equal to NULL for GPUs that do not

-:42: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!pos" #42: FILE: drivers/gpu/drm/i915/gvt/kvmgt.c:560:
+ if (pos == NULL) {

-:47: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Alejandro Sior <[email protected]>'

total: 0 errors, 2 warnings, 1 checks, 10 lines checked

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

#2 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for Fixed NULL pointer dereference in handle_edid functions for GPUs that do not support EDID

In reply to Alejandro Sior
== Series Details ==

== Series Details ==

Series: Fixed NULL pointer dereference in handle_edid functions for GPUs that do not support EDID
URL : https://patchwork.freedesktop.org/series/81463/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8982 -> Patchwork_18454
====================================================

Summary
-------

**FAILURE**

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

If you think the reported changes have nothing to do with the changes introduced in Patchwork_18454, 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/Patchwork_18454/index.html

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

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

### IGT changes ###

#### Possible regressions ####

* igt@gem_exec_gttfill@basic:
- fi-kbl-7500u: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-kbl-7500u/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-kbl-7500u/igt@[email protected]

* igt@gem_exec_parallel@engines@basic:
- fi-skl-6600u: NOTRUN -> [INCOMPLETE][3]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-skl-6600u/igt@gem_exec_parallel@[email protected]

* igt@gem_exec_parallel@engines@contexts:
- fi-byt-j1900: [PASS][4] -> [INCOMPLETE][5]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-byt-j1900/igt@gem_exec_parallel@[email protected]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-byt-j1900/igt@gem_exec_parallel@[email protected]

* igt@i915_selftest@live@gem_execbuf:
- fi-bsw-nick: [PASS][6] -> [INCOMPLETE][7]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-bsw-nick/igt@i915_selftest@live@gem_execbuf.html
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-bsw-nick/igt@i915_selftest@live@gem_execbuf.html
- fi-ilk-650: NOTRUN -> [INCOMPLETE][8]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-ilk-650/igt@i915_selftest@live@gem_execbuf.html

* igt@runner@aborted:
- fi-byt-j1900: NOTRUN -> [FAIL][9]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-byt-j1900/igt@[email protected]

#### Warnings ####

* igt@runner@aborted:
- fi-bdw-5557u: [FAIL][10] ([i915#483]) -> [FAIL][11]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-bdw-5557u/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-bdw-5557u/igt@[email protected]

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@gem_exec_parallel@engines@contexts:
- {fi-ehl-1}: NOTRUN -> [INCOMPLETE][12]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-ehl-1/igt@gem_exec_parallel@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live@gem_execbuf:
- fi-snb-2600: [PASS][13] -> [INCOMPLETE][14] ([i915#82])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-snb-2600/igt@i915_selftest@live@gem_execbuf.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-snb-2600/igt@i915_selftest@live@gem_execbuf.html

#### Possible fixes ####

* igt@gem_exec_gttfill@basic:
- fi-skl-6600u: [INCOMPLETE][15] -> [PASS][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-skl-6600u/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-skl-6600u/igt@[email protected]
- fi-ilk-650: [INCOMPLETE][17] -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-ilk-650/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-ilk-650/igt@[email protected]

* igt@gem_exec_parallel@engines@basic:
- {fi-ehl-1}: [INCOMPLETE][19] -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-ehl-1/igt@gem_exec_parallel@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-ehl-1/igt@gem_exec_parallel@[email protected]

* igt@i915_selftest@live@gem_execbuf:
- fi-gdg-551: [INCOMPLETE][21] ([i915#172]) -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-gdg-551/igt@i915_selftest@live@gem_execbuf.html
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-gdg-551/igt@i915_selftest@live@gem_execbuf.html
- fi-snb-2520m: [INCOMPLETE][23] -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-snb-2520m/igt@i915_selftest@live@gem_execbuf.html
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-snb-2520m/igt@i915_selftest@live@gem_execbuf.html

#### Warnings ####

* igt@runner@aborted:
- fi-kbl-x1275: [FAIL][25] ([i915#1186] / [i915#1784]) -> [FAIL][26] ([i915#1186])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-kbl-x1275/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-kbl-x1275/igt@[email protected]
- fi-skl-6600u: [FAIL][27] ([i915#1186]) -> [FAIL][28] ([i915#2398])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-skl-6600u/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-skl-6600u/igt@[email protected]
- fi-kbl-r: [FAIL][29] ([i915#1186] / [i915#1784]) -> [FAIL][30] ([i915#1186])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-kbl-r/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-kbl-r/igt@[email protected]
- fi-kbl-7500u: [FAIL][31] ([i915#2398]) -> [FAIL][32] ([i915#1186] / [i915#1784])
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-kbl-7500u/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-kbl-7500u/igt@[email protected]
- fi-kbl-guc: [FAIL][33] ([i915#1186]) -> [FAIL][34] ([i915#1186] / [i915#1784])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-kbl-guc/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-kbl-guc/igt@[email protected]
- fi-cml-s: [FAIL][35] ([i915#1186] / [i915#2082]) -> [FAIL][36] ([i915#1186])
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8982/fi-cml-s/igt@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18454/fi-cml-s/igt@[email protected]

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

[i915#1186]: https://gitlab.freedesktop.org/drm/intel/issues/1186
[i915#172]: https://gitlab.freedesktop.org/drm/intel/issues/172
[i915#1784]: https://gitlab.freedesktop.org/drm/intel/issues/1784
[i915#1814]: https://gitlab.freedesktop.org/drm/intel/issues/1814
[i915#2082]: https://gitlab.freedesktop.org/drm/intel/issues/2082
[i915#2398]: https://gitlab.freedesktop.org/drm/intel/issues/2398
[i915#2417]: https://gitlab.freedesktop.org/drm/intel/issues/2417
[i915#483]: https://gitlab.freedesktop.org/drm/intel/issues/483
[i915#82]: https://gitlab.freedesktop.org/drm/intel/issues/82

Participating hosts (42 -> 36)
------------------------------

Missing (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-byt-clapper fi-bdw-samus

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

* Linux: CI_DRM_8982 -> Patchwork_18454

CI-20190529: 20190529
CI_DRM_8982: 666ff2a4ca80b0715a8709ef5462d16b8c92d8ef @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5779: f52bf19b5f02d52fc3e201c6467ec3f511227fba @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_18454: 24f0f91b0b97a62f3d3d6d8303f09d42e68918b9 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

24f0f91b0b97 Fixed NULL pointer dereference in handle_edid functions for GPUs that do not support EDID

== Logs ==

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

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