Skip to contentSkip to conversation

drm/i915: Avoid potential vm use-after-free

PATCH In review Rob Clark 4 participants 6 messages Jan 19, 2023 – Jan 27, 2023

Subsystems (2)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 drm/i915: Avoid potential vm use-after-free

From: Rob Clark <[email protected]>

Adding the vm to the vm_xa table makes it visible to userspace, which could try to race with us to close the vm. So we need to take our extra reference before putting it in the table.

---
Note, you could list commit e1a7ab4fca0c ("drm/i915: Remove the vm open count") as the "fixed" commit, but really the issue seems to go back much further (with the fix needing some backporting in the process).

 drivers/gpu/drm/i915/gem/i915_gem_context.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +11 -3
index 6250de9b9196..e4b78ab4773b 100644
@@ -1861,11 +1861,19 @@ static int get_ppgtt(struct drm_i915_file_private *file_priv,
 	vm = ctx->vm;
 	GEM_BUG_ON(!vm);
 
+	/*
+	 * Get a reference for the allocated handle.  Once the handle is
+	 * visible in the vm_xa table, userspace could try to close it
+	 * from under our feet, so we need to hold the extra reference
+	 * first.
+	 */
+	i915_vm_get(vm);
+
 	err = xa_alloc(&file_priv->vm_xa, &id, vm, xa_limit_32b, GFP_KERNEL);
-	if (err)
+	if (err) {
+		i915_vm_put(vm);
 		return err;
-
-	i915_vm_get(vm);
+	}
 
 	GEM_BUG_ON(id == 0); /* reserved for invalid/unassigned ppgtt */
 	args->value = id;
Signature · 1 line
2.38.1
#1 lore raw

[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Avoid potential vm use-after-free

== Series Details ==

== Series Details ==

Series: drm/i915: Avoid potential vm use-after-free
URL : https://patchwork.freedesktop.org/series/113105/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_12613 -> Patchwork_113105v1
====================================================

Summary
-------

**SUCCESS**

No regressions found.

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

Participating hosts (38 -> 35)
------------------------------

Missing (3): fi-kbl-soraka fi-rkl-11600 fi-snb-2520m

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

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

### IGT changes ###

#### Suppressed ####

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

* igt@i915_selftest@live@gt_mocs:
- {bat-rpls-1}: [PASS][1] -> [DMESG-FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/bat-rpls-1/igt@i915_selftest@live@gt_mocs.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/bat-rpls-1/igt@i915_selftest@live@gt_mocs.html

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_lmem_swapping@basic:
- fi-apl-guc: NOTRUN -> [SKIP][3] ([fdo#109271] / [i915#4613]) +3 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/fi-apl-guc/igt@[email protected]

* igt@kms_chamelium_hpd@common-hpd-after-suspend:
- fi-apl-guc: NOTRUN -> [SKIP][4] ([fdo#109271]) +1 similar issue
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/fi-apl-guc/igt@[email protected]

#### Possible fixes ####

* igt@fbdev@write:
- fi-blb-e6850: [SKIP][5] ([fdo#109271]) -> [PASS][6] +4 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/fi-blb-e6850/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/fi-blb-e6850/igt@[email protected]

* igt@i915_selftest@live@migrate:
- {bat-adlp-6}: [DMESG-FAIL][7] ([i915#7699]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/bat-adlp-6/igt@i915_selftest@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/bat-adlp-6/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@slpc:
- {bat-rpls-1}: [DMESG-FAIL][9] ([i915#6367]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/bat-rpls-1/igt@i915_selftest@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/bat-rpls-1/igt@i915_selftest@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor@atomic-transitions:
- fi-bsw-n3050: [FAIL][11] ([i915#6298]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/fi-bsw-n3050/igt@kms_cursor_legacy@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/fi-bsw-n3050/igt@kms_cursor_legacy@[email protected]

* igt@kms_pipe_crc_basic@suspend-read-crc@pipe-c-dp-3:
- {bat-dg2-9}: [FAIL][13] -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/bat-dg2-9/igt@kms_pipe_crc_basic@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/bat-dg2-9/igt@kms_pipe_crc_basic@[email protected]

* igt@prime_self_import@basic-with_one_bo_two_files:
- fi-apl-guc: [DMESG-WARN][15] -> [PASS][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/fi-apl-guc/igt@prime_self_import@basic-with_one_bo_two_files.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/fi-apl-guc/igt@prime_self_import@basic-with_one_bo_two_files.html

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

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
[i915#6257]: https://gitlab.freedesktop.org/drm/intel/issues/6257
[i915#6298]: https://gitlab.freedesktop.org/drm/intel/issues/6298
[i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
[i915#7699]: https://gitlab.freedesktop.org/drm/intel/issues/7699

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

* Linux: CI_DRM_12613 -> Patchwork_113105v1

CI-20190529: 20190529
CI_DRM_12613: c79a53a6143abdc789b46eb24cd7ce00924be491 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7126: 3aa9364a1e478010aba0d3dfe9183486560ecc60 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_113105v1: c79a53a6143abdc789b46eb24cd7ce00924be491 @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

3e2e2545a66d drm/i915: Avoid potential vm use-after-free

== Logs ==

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

#2 lore raw

[Intel-gfx] ✓ Fi.CI.IGT: success for drm/i915: Avoid potential vm use-after-free

In reply to Rob Clark
== Series Details ==

== Series Details ==

Series: drm/i915: Avoid potential vm use-after-free
URL : https://patchwork.freedesktop.org/series/113105/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_12613_full -> Patchwork_113105v1_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

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

Participating hosts (12 -> 10)
------------------------------

Missing (2): pig-skl-6260u pig-kbl-iris

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

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

### IGT changes ###

#### Issues hit ####

* igt@kms_cursor_legacy@flip-vs-cursor@atomic-transitions:
- shard-glk: [PASS][1] -> [FAIL][2] ([i915#2346])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-glk8/igt@kms_cursor_legacy@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-glk8/igt@kms_cursor_legacy@[email protected]

* igt@kms_flip@flip-vs-expired-vblank@a-hdmi-a1:
- shard-glk: [PASS][3] -> [FAIL][4] ([i915#79])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-glk9/igt@kms_flip@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-glk9/igt@kms_flip@[email protected]

#### Possible fixes ####

* igt@fbdev@unaligned-write:
- {shard-rkl}: [SKIP][5] ([i915#2582]) -> [PASS][6] +1 similar issue
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-1/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@[email protected]

* igt@gem_exec_reloc@basic-gtt-read-noreloc:
- {shard-rkl}: [SKIP][7] ([i915#3281]) -> [PASS][8] +4 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-6/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-5/igt@[email protected]

* igt@gem_mmap_gtt@coherency:
- {shard-rkl}: [SKIP][9] ([fdo#111656]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-6/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-5/igt@[email protected]

* igt@gem_partial_pwrite_pread@writes-after-reads-snoop:
- {shard-rkl}: [SKIP][11] ([i915#3282]) -> [PASS][12] +1 similar issue
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-1/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-5/igt@[email protected]

* igt@gen9_exec_parse@secure-batches:
- {shard-rkl}: [SKIP][13] ([i915#2527]) -> [PASS][14] +1 similar issue
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-1/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-5/igt@[email protected]

* igt@i915_pm_rpm@dpms-mode-unset-lpsp:
- {shard-rkl}: [SKIP][15] ([i915#1397]) -> [PASS][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-1/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@[email protected]

* igt@i915_pm_rpm@i2c:
- {shard-rkl}: [SKIP][17] ([fdo#109308]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-4/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@[email protected]

* igt@i915_selftest@live@gt_heartbeat:
- shard-glk: [DMESG-FAIL][19] ([i915#5334]) -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-glk2/igt@i915_selftest@live@gt_heartbeat.html
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-glk7/igt@i915_selftest@live@gt_heartbeat.html

* igt@kms_dp_aux_dev:
- {shard-rkl}: [SKIP][21] ([i915#1257]) -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-4/igt@kms_dp_aux_dev.html
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@kms_dp_aux_dev.html

* igt@kms_fbcon_fbt@psr-suspend:
- {shard-rkl}: [SKIP][23] ([fdo#110189] / [i915#3955]) -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-1/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-shrfb-scaledprimary:
- {shard-rkl}: [SKIP][25] ([i915#1849] / [i915#4098]) -> [PASS][26] +17 similar issues
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-4/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@[email protected]

* igt@kms_plane@plane-position-hole@pipe-b-planes:
- {shard-rkl}: [SKIP][27] ([i915#1849]) -> [PASS][28] +5 similar issues
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-4/igt@kms_plane@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@kms_plane@[email protected]

* igt@kms_psr@sprite_plane_onoff:
- {shard-rkl}: [SKIP][29] ([i915#1072]) -> [PASS][30] +1 similar issue
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-4/igt@kms_psr@sprite_plane_onoff.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@kms_psr@sprite_plane_onoff.html

* igt@kms_psr_stress_test@invalidate-primary-flip-overlay:
- {shard-rkl}: [SKIP][31] ([i915#5461]) -> [PASS][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-4/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@[email protected]

* igt@kms_universal_plane@universal-plane-pageflip-windowed-pipe-a:
- {shard-rkl}: [SKIP][33] ([i915#4098]) -> [PASS][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-4/igt@kms_universal_plane@universal-plane-pageflip-windowed-pipe-a.html
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@kms_universal_plane@universal-plane-pageflip-windowed-pipe-a.html

* igt@kms_vblank@pipe-b-query-idle:
- {shard-rkl}: [SKIP][35] ([i915#1845] / [i915#4098]) -> [PASS][36] +22 similar issues
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-1/igt@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@[email protected]

* igt@perf@gen12-oa-tlb-invalidate:
- {shard-rkl}: [SKIP][37] ([fdo#109289]) -> [PASS][38]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12613/shard-rkl-5/igt@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-2/igt@[email protected]

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

[fdo#109274]: https://bugs.freedesktop.org/show_bug.cgi?id=109274
[fdo#109279]: https://bugs.freedesktop.org/show_bug.cgi?id=109279
[fdo#109280]: https://bugs.freedesktop.org/show_bug.cgi?id=109280
[fdo#109283]: https://bugs.freedesktop.org/show_bug.cgi?id=109283
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
[fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295
[fdo#109302]: https://bugs.freedesktop.org/show_bug.cgi?id=109302
[fdo#109303]: https://bugs.freedesktop.org/show_bug.cgi?id=109303
[fdo#109307]: https://bugs.freedesktop.org/show_bug.cgi?id=109307
[fdo#109308]: https://bugs.freedesktop.org/show_bug.cgi?id=109308
[fdo#109312]: https://bugs.freedesktop.org/show_bug.cgi?id=109312
[fdo#109313]: https://bugs.freedesktop.org/show_bug.cgi?id=109313
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#109506]: https://bugs.freedesktop.org/show_bug.cgi?id=109506
[fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
[fdo#110189]: https://bugs.freedesktop.org/show_bug.cgi?id=110189
[fdo#110542]: https://bugs.freedesktop.org/show_bug.cgi?id=110542
[fdo#110723]: https://bugs.freedesktop.org/show_bug.cgi?id=110723
[fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
[fdo#111614]: https://bugs.freedesktop.org/show_bug.cgi?id=111614
[fdo#111615]: https://bugs.freedesktop.org/show_bug.cgi?id=111615
[fdo#111644]: https://bugs.freedesktop.org/show_bug.cgi?id=111644
[fdo#111656]: https://bugs.freedesktop.org/show_bug.cgi?id=111656
[fdo#111825]: https://bugs.freedesktop.org/show_bug.cgi?id=111825
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[fdo#112054]: https://bugs.freedesktop.org/show_bug.cgi?id=112054
[fdo#112283]: https://bugs.freedesktop.org/show_bug.cgi?id=112283
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1257]: https://gitlab.freedesktop.org/drm/intel/issues/1257
[i915#132]: https://gitlab.freedesktop.org/drm/intel/issues/132
[i915#1397]: https://gitlab.freedesktop.org/drm/intel/issues/1397
[i915#1769]: https://gitlab.freedesktop.org/drm/intel/issues/1769
[i915#1825]: https://gitlab.freedesktop.org/drm/intel/issues/1825
[i915#1839]: https://gitlab.freedesktop.org/drm/intel/issues/1839
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#1849]: https://gitlab.freedesktop.org/drm/intel/issues/1849
[i915#1850]: https://gitlab.freedesktop.org/drm/intel/issues/1850
[i915#1902]: https://gitlab.freedesktop.org/drm/intel/issues/1902
[i915#2346]: https://gitlab.freedesktop.org/drm/intel/issues/2346
[i915#2434]: https://gitlab.freedesktop.org/drm/intel/issues/2434
[i915#2436]: https://gitlab.freedesktop.org/drm/intel/issues/2436
[i915#2437]: https://gitlab.freedesktop.org/drm/intel/issues/2437
[i915#2527]: https://gitlab.freedesktop.org/drm/intel/issues/2527
[i915#2575]: https://gitlab.freedesktop.org/drm/intel/issues/2575
[i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
[i915#2587]: https://gitlab.freedesktop.org/drm/intel/issues/2587
[i915#2658]: https://gitlab.freedesktop.org/drm/intel/issues/2658
[i915#2672]: https://gitlab.freedesktop.org/drm/intel/issues/2672
[i915#2681]: https://gitlab.freedesktop.org/drm/intel/issues/2681
[i915#2705]: https://gitlab.freedesktop.org/drm/intel/issues/2705
[i915#280]: https://gitlab.freedesktop.org/drm/intel/issues/280
[i915#284]: https://gitlab.freedesktop.org/drm/intel/issues/284
[i915#2842]: https://gitlab.freedesktop.org/drm/intel/issues/2842
[i915#2856]: https://gitlab.freedesktop.org/drm/intel/issues/2856
[i915#2920]: https://gitlab.freedesktop.org/drm/intel/issues/2920
[i915#2994]: https://gitlab.freedesktop.org/drm/intel/issues/2994
[i915#3116]: https://gitlab.freedesktop.org/drm/intel/issues/3116
[i915#315]: https://gitlab.freedesktop.org/drm/intel/issues/315
[i915#3281]: https://gitlab.freedesktop.org/drm/intel/issues/3281
[i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
[i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
[i915#3297]: https://gitlab.freedesktop.org/drm/intel/issues/3297
[i915#3299]: https://gitlab.freedesktop.org/drm/intel/issues/3299
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#3318]: https://gitlab.freedesktop.org/drm/intel/issues/3318
[i915#3323]: https://gitlab.freedesktop.org/drm/intel/issues/3323
[i915#3359]: https://gitlab.freedesktop.org/drm/intel/issues/3359
[i915#3361]: https://gitlab.freedesktop.org/drm/intel/issues/3361
[i915#3458]: https://gitlab.freedesktop.org/drm/intel/issues/3458
[i915#3539]: https://gitlab.freedesktop.org/drm/intel/issues/3539
[i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
[i915#3547]: https://gitlab.freedesktop.org/drm/intel/issues/3547
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3637]: https://gitlab.freedesktop.org/drm/intel/issues/3637
[i915#3638]: https://gitlab.freedesktop.org/drm/intel/issues/3638
[i915#3689]: https://gitlab.freedesktop.org/drm/intel/issues/3689
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#3734]: https://gitlab.freedesktop.org/drm/intel/issues/3734
[i915#3742]: https://gitlab.freedesktop.org/drm/intel/issues/3742
[i915#3826]: https://gitlab.freedesktop.org/drm/intel/issues/3826
[i915#3840]: https://gitlab.freedesktop.org/drm/intel/issues/3840
[i915#3886]: https://gitlab.freedesktop.org/drm/intel/issues/3886
[i915#3955]: https://gitlab.freedesktop.org/drm/intel/issues/3955
[i915#3966]: https://gitlab.freedesktop.org/drm/intel/issues/3966
[i915#3989]: https://gitlab.freedesktop.org/drm/intel/issues/3989
[i915#404]: https://gitlab.freedesktop.org/drm/intel/issues/404
[i915#4070]: https://gitlab.freedesktop.org/drm/intel/issues/4070
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4098]: https://gitlab.freedesktop.org/drm/intel/issues/4098
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#426]: https://gitlab.freedesktop.org/drm/intel/issues/426
[i915#4270]: https://gitlab.freedesktop.org/drm/intel/issues/4270
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4349]: https://gitlab.freedesktop.org/drm/intel/issues/4349
[i915#4391]: https://gitlab.freedesktop.org/drm/intel/issues/4391
[i915#4538]: https://gitlab.freedesktop.org/drm/intel/issues/4538
[i915#454]: https://gitlab.freedesktop.org/drm/intel/issues/454
[i915#4565]: https://gitlab.freedesktop.org/drm/intel/issues/4565
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4767]: https://gitlab.freedesktop.org/drm/intel/issues/4767
[i915#4812]: https://gitlab.freedesktop.org/drm/intel/issues/4812
[i915#4818]: https://gitlab.freedesktop.org/drm/intel/issues/4818
[i915#4833]: https://gitlab.freedesktop.org/drm/intel/issues/4833
[i915#4852]: https://gitlab.freedesktop.org/drm/intel/issues/4852
[i915#4860]: https://gitlab.freedesktop.org/drm/intel/issues/4860
[i915#4877]: https://gitlab.freedesktop.org/drm/intel/issues/4877
[i915#4880]: https://gitlab.freedesktop.org/drm/intel/issues/4880
[i915#4881]: https://gitlab.freedesktop.org/drm/intel/issues/4881
[i915#4884]: https://gitlab.freedesktop.org/drm/intel/issues/4884
[i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
[i915#5176]: https://gitlab.freedesktop.org/drm/intel/issues/5176
[i915#5235]: https://gitlab.freedesktop.org/drm/intel/issues/5235
[i915#5286]: https://gitlab.freedesktop.org/drm/intel/issues/5286
[i915#5288]: https://gitlab.freedesktop.org/drm/intel/issues/5288
[i915#5289]: https://gitlab.freedesktop.org/drm/intel/issues/5289
[i915#5325]: https://gitlab.freedesktop.org/drm/intel/issues/5325
[i915#5327]: https://gitlab.freedesktop.org/drm/intel/issues/5327
[i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533
[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#5439]: https://gitlab.freedesktop.org/drm/intel/issues/5439
[i915#5461]: https://gitlab.freedesktop.org/drm/intel/issues/5461
[i915#5563]: https://gitlab.freedesktop.org/drm/intel/issues/5563
[i915#6095]: https://gitlab.freedesktop.org/drm/intel/issues/6095
[i915#6117]: https://gitlab.freedesktop.org/drm/intel/issues/6117
[i915#6227]: https://gitlab.freedesktop.org/drm/intel/issues/6227
[i915#6230]: https://gitlab.freedesktop.org/drm/intel/issues/6230
[i915#6245]: https://gitlab.freedesktop.org/drm/intel/issues/6245
[i915#6248]: https://gitlab.freedesktop.org/drm/intel/issues/6248
[i915#6301]: https://gitlab.freedesktop.org/drm/intel/issues/6301
[i915#6335]: https://gitlab.freedesktop.org/drm/intel/issues/6335
[i915#6344]: https://gitlab.freedesktop.org/drm/intel/issues/6344
[i915#6355]: https://gitlab.freedesktop.org/drm/intel/issues/6355
[i915#6433]: https://gitlab.freedesktop.org/drm/intel/issues/6433
[i915#6463]: https://gitlab.freedesktop.org/drm/intel/issues/6463
[i915#6497]: https://gitlab.freedesktop.org/drm/intel/issues/6497
[i915#6524]: https://gitlab.freedesktop.org/drm/intel/issues/6524
[i915#658]: https://gitlab.freedesktop.org/drm/intel/issues/658
[i915#6590]: https://gitlab.freedesktop.org/drm/intel/issues/6590
[i915#6768]: https://gitlab.freedesktop.org/drm/intel/issues/6768
[i915#6944]: https://gitlab.freedesktop.org/drm/intel/issues/6944
[i915#6946]: https://gitlab.freedesktop.org/drm/intel/issues/6946
[i915#6953]: https://gitlab.freedesktop.org/drm/intel/issues/6953
[i915#7037]: https://gitlab.freedesktop.org/drm/intel/issues/7037
[i915#7116]: https://gitlab.freedesktop.org/drm/intel/issues/7116
[i915#7118]: https://gitlab.freedesktop.org/drm/intel/issues/7118
[i915#7128]: https://gitlab.freedesktop.org/drm/intel/issues/7128
[i915#7294]: https://gitlab.freedesktop.org/drm/intel/issues/7294
[i915#7561]: https://gitlab.freedesktop.org/drm/intel/issues/7561
[i915#7651]: https://gitlab.freedesktop.org/drm/intel/issues/7651
[i915#7697]: https://gitlab.freedesktop.org/drm/intel/issues/7697
[i915#7701]: https://gitlab.freedesktop.org/drm/intel/issues/7701
[i915#7711]: https://gitlab.freedesktop.org/drm/intel/issues/7711
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
[i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79

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

* Linux: CI_DRM_12613 -> Patchwork_113105v1
* Piglit: piglit_4509 -> None

CI-20190529: 20190529
CI_DRM_12613: c79a53a6143abdc789b46eb24cd7ce00924be491 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7126: 3aa9364a1e478010aba0d3dfe9183486560ecc60 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_113105v1: c79a53a6143abdc789b46eb24cd7ce00924be491 @ 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_113105v1/index.html

#3 lore raw
In reply to Rob Clark

+ some more people based on e1a7ab4fca0c

Quoted 11 lines · Rob Clark

From: Rob Clark <[email protected]>

Adding the vm to the vm_xa table makes it visible to userspace, which could try to race with us to close the vm. So we need to take our extra reference before putting it in the table.

---
Note, you could list commit e1a7ab4fca0c ("drm/i915: Remove the vm open count") as the "fixed" commit, but really the issue seems to go back much further (with the fix needing some backporting in the process).

It would probably be rather essential to identify the correct Fixes: tag.

Since Thomas, Matt and Niranjana you were directly involved in the patch which changed significantly how this works, perhaps there is something still somewhat easily retrievable from your memory lanes to help with this?

Regards,

Tvrtko

Quoted 31 lines
  drivers/gpu/drm/i915/gem/i915_gem_context.c | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +11 -3
index 6250de9b9196..e4b78ab4773b 100644
@@ -1861,11 +1861,19 @@ static int get_ppgtt(struct drm_i915_file_private *file_priv,
  	vm = ctx->vm;
  	GEM_BUG_ON(!vm);
 
+	/*
+	 * Get a reference for the allocated handle.  Once the handle is
+	 * visible in the vm_xa table, userspace could try to close it
+	 * from under our feet, so we need to hold the extra reference
+	 * first.
+	 */
+	i915_vm_get(vm);
+
  	err = xa_alloc(&file_priv->vm_xa, &id, vm, xa_limit_32b, GFP_KERNEL);
-	if (err)
+	if (err) {
+		i915_vm_put(vm);
  		return err;
-
-	i915_vm_get(vm);
+	}
 
  	GEM_BUG_ON(id == 0); /* reserved for invalid/unassigned ppgtt */
  	args->value = id;
Reviewed-by
#4 lore raw
Quoted 17 lines · Tvrtko Ursulin

+ some more people based on e1a7ab4fca0c

Quoted 11 lines · Rob Clark

From: Rob Clark <[email protected]>

Adding the vm to the vm_xa table makes it visible to userspace, which could try to race with us to close the vm. So we need to take our extra reference before putting it in the table.

---
Note, you could list commit e1a7ab4fca0c ("drm/i915: Remove the vm open count") as the "fixed" commit, but really the issue seems to go back much further (with the fix needing some backporting in the process).

Quoted 5 lines

It would probably be rather essential to identify the correct Fixes: tag.

Since Thomas, Matt and Niranjana you were directly involved in the patch which changed significantly how this works, perhaps there is something still somewhat easily retrievable from your memory lanes to help with this?

Sorry for the delay. Fix looks good to me,

Looking at the git history, the fixes tag I think needs to be:

Fixes 9ec8795e7d91 ("drm/i915: Drop __rcu from gem_context->vm")
Cc <[email protected]> # v5.16+
Quoted 36 lines

Regards,

Tvrtko

Quoted 31 lines
  drivers/gpu/drm/i915/gem/i915_gem_context.c | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +11 -3
index 6250de9b9196..e4b78ab4773b 100644
@@ -1861,11 +1861,19 @@ static int get_ppgtt(struct drm_i915_file_private *file_priv,
      vm = ctx->vm;
      GEM_BUG_ON(!vm);
 
+     /*
+      * Get a reference for the allocated handle.  Once the handle is
+      * visible in the vm_xa table, userspace could try to close it
+      * from under our feet, so we need to hold the extra reference
+      * first.
+      */
+     i915_vm_get(vm);
+
      err = xa_alloc(&file_priv->vm_xa, &id, vm, xa_limit_32b, GFP_KERNEL);
-     if (err)
+     if (err) {
+             i915_vm_put(vm);
              return err;
-
-     i915_vm_get(vm);
+     }
 
      GEM_BUG_ON(id == 0); /* reserved for invalid/unassigned ppgtt */
      args->value = id;
#5 lore raw
Quoted 25 lines · Matthew Auld
Quoted 17 lines · Tvrtko Ursulin

+ some more people based on e1a7ab4fca0c

Quoted 11 lines · Rob Clark

From: Rob Clark <[email protected]>

Adding the vm to the vm_xa table makes it visible to userspace, which could try to race with us to close the vm. So we need to take our extra reference before putting it in the table.

---
Note, you could list commit e1a7ab4fca0c ("drm/i915: Remove the vm open count") as the "fixed" commit, but really the issue seems to go back much further (with the fix needing some backporting in the process).

Quoted 5 lines

It would probably be rather essential to identify the correct Fixes: tag.

Since Thomas, Matt and Niranjana you were directly involved in the patch which changed significantly how this works, perhaps there is something still somewhat easily retrievable from your memory lanes to help with this?

Quoted 7 lines

Sorry for the delay. Fix looks good to me,

Looking at the git history, the fixes tag I think needs to be:

Fixes 9ec8795e7d91 ("drm/i915: Drop __rcu from gem_context->vm")
Cc <[email protected]> # v5.16+

As discussed offline this looks correct to me too. Thanks for looking into it!

Since the CI was green I have now merged the patch. Thanks for the fix Rob!

Regards,

Tvrtko

P.S. Backport to kernels which do not contain e1a7ab4fca0c ("drm/i915: Remove the vm open count"), so 5.16 to 5.18, will require a slightly different patch as Matt has also mentioned offline.

Quoted 37 lines
Quoted 37 lines

Regards,

Tvrtko

Quoted 31 lines
   drivers/gpu/drm/i915/gem/i915_gem_context.c | 14 +++++++++++---
   1 file changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +11 -3
index 6250de9b9196..e4b78ab4773b 100644
@@ -1861,11 +1861,19 @@ static int get_ppgtt(struct drm_i915_file_private *file_priv,
       vm = ctx->vm;
       GEM_BUG_ON(!vm);
 
+     /*
+      * Get a reference for the allocated handle.  Once the handle is
+      * visible in the vm_xa table, userspace could try to close it
+      * from under our feet, so we need to hold the extra reference
+      * first.
+      */
+     i915_vm_get(vm);
+
       err = xa_alloc(&file_priv->vm_xa, &id, vm, xa_limit_32b, GFP_KERNEL);
-     if (err)
+     if (err) {
+             i915_vm_put(vm);
               return err;
-
-     i915_vm_get(vm);
+     }
 
       GEM_BUG_ON(id == 0); /* reserved for invalid/unassigned ppgtt */
       args->value = id;