* [Intel-gfx] [PATCH] drm/i915: Avoid potential vm use-after-free
@ 2023-01-19 17:32 Rob Clark
2023-01-19 18:42 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Rob Clark @ 2023-01-19 17:32 UTC (permalink / raw)
To: dri-devel
Cc: Rob Clark, Thomas Hellström, intel-gfx, open list,
Chris Wilson, Daniel Vetter, Rodrigo Vivi, David Airlie,
katrinzhou
From: Rob Clark <robdclark@chromium.org>
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.
Signed-off-by: Rob Clark <robdclark@chromium.org>
---
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(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 6250de9b9196..e4b78ab4773b 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -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;
--
2.38.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Avoid potential vm use-after-free 2023-01-19 17:32 [Intel-gfx] [PATCH] drm/i915: Avoid potential vm use-after-free Rob Clark @ 2023-01-19 18:42 ` Patchwork 2023-01-20 22:03 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork 2023-01-23 16:56 ` [Intel-gfx] [PATCH] " Tvrtko Ursulin 2 siblings, 0 replies; 6+ messages in thread From: Patchwork @ 2023-01-19 18:42 UTC (permalink / raw) To: Rob Clark; +Cc: intel-gfx [-- Attachment #1: Type: text/plain, Size: 5359 bytes --] == 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@gem_lmem_swapping@basic.html * 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@kms_chamelium_hpd@common-hpd-after-suspend.html #### 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@fbdev@write.html [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/fi-blb-e6850/igt@fbdev@write.html * 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@live@migrate.html [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/bat-adlp-6/igt@i915_selftest@live@migrate.html * 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@live@slpc.html [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/bat-rpls-1/igt@i915_selftest@live@slpc.html * 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@basic-busy-flip-before-cursor@atomic-transitions.html [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/fi-bsw-n3050/igt@kms_cursor_legacy@basic-busy-flip-before-cursor@atomic-transitions.html * 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@suspend-read-crc@pipe-c-dp-3.html [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/bat-dg2-9/igt@kms_pipe_crc_basic@suspend-read-crc@pipe-c-dp-3.html * 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 [-- Attachment #2: Type: text/html, Size: 6061 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Intel-gfx] ✓ Fi.CI.IGT: success for drm/i915: Avoid potential vm use-after-free 2023-01-19 17:32 [Intel-gfx] [PATCH] drm/i915: Avoid potential vm use-after-free Rob Clark 2023-01-19 18:42 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork @ 2023-01-20 22:03 ` Patchwork 2023-01-23 16:56 ` [Intel-gfx] [PATCH] " Tvrtko Ursulin 2 siblings, 0 replies; 6+ messages in thread From: Patchwork @ 2023-01-20 22:03 UTC (permalink / raw) To: Rob Clark; +Cc: intel-gfx [-- Attachment #1: Type: text/plain, Size: 19032 bytes --] == 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@flip-vs-cursor@atomic-transitions.html [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-glk8/igt@kms_cursor_legacy@flip-vs-cursor@atomic-transitions.html * 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@flip-vs-expired-vblank@a-hdmi-a1.html [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-glk9/igt@kms_flip@flip-vs-expired-vblank@a-hdmi-a1.html #### 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@fbdev@unaligned-write.html [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@fbdev@unaligned-write.html * 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@gem_exec_reloc@basic-gtt-read-noreloc.html [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-5/igt@gem_exec_reloc@basic-gtt-read-noreloc.html * 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@gem_mmap_gtt@coherency.html [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-5/igt@gem_mmap_gtt@coherency.html * 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@gem_partial_pwrite_pread@writes-after-reads-snoop.html [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-5/igt@gem_partial_pwrite_pread@writes-after-reads-snoop.html * 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@gen9_exec_parse@secure-batches.html [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-5/igt@gen9_exec_parse@secure-batches.html * 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@i915_pm_rpm@dpms-mode-unset-lpsp.html [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@i915_pm_rpm@dpms-mode-unset-lpsp.html * 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@i915_pm_rpm@i2c.html [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@i915_pm_rpm@i2c.html * 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@kms_fbcon_fbt@psr-suspend.html [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@kms_fbcon_fbt@psr-suspend.html * 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@kms_frontbuffer_tracking@fbc-shrfb-scaledprimary.html [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@kms_frontbuffer_tracking@fbc-shrfb-scaledprimary.html * 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@plane-position-hole@pipe-b-planes.html [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@kms_plane@plane-position-hole@pipe-b-planes.html * 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@kms_psr_stress_test@invalidate-primary-flip-overlay.html [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@kms_psr_stress_test@invalidate-primary-flip-overlay.html * 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@kms_vblank@pipe-b-query-idle.html [36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-6/igt@kms_vblank@pipe-b-query-idle.html * 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@perf@gen12-oa-tlb-invalidate.html [38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113105v1/shard-rkl-2/igt@perf@gen12-oa-tlb-invalidate.html {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 [-- Attachment #2: Type: text/html, Size: 11016 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: Avoid potential vm use-after-free 2023-01-19 17:32 [Intel-gfx] [PATCH] drm/i915: Avoid potential vm use-after-free Rob Clark 2023-01-19 18:42 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork 2023-01-20 22:03 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork @ 2023-01-23 16:56 ` Tvrtko Ursulin 2023-01-27 13:10 ` Matthew Auld 2 siblings, 1 reply; 6+ messages in thread From: Tvrtko Ursulin @ 2023-01-23 16:56 UTC (permalink / raw) To: Rob Clark, dri-devel Cc: Rob Clark, Thomas Hellström, intel-gfx, open list, Chris Wilson, Matthew Auld, Daniel Vetter, Rodrigo Vivi, David Airlie, katrinzhou + some more people based on e1a7ab4fca0c On 19/01/2023 17:32, Rob Clark wrote: > From: Rob Clark <robdclark@chromium.org> > > 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. > > Signed-off-by: Rob Clark <robdclark@chromium.org> > --- > 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 > > drivers/gpu/drm/i915/gem/i915_gem_context.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c > index 6250de9b9196..e4b78ab4773b 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c > +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c > @@ -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; ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: Avoid potential vm use-after-free 2023-01-23 16:56 ` [Intel-gfx] [PATCH] " Tvrtko Ursulin @ 2023-01-27 13:10 ` Matthew Auld 2023-01-27 13:50 ` Tvrtko Ursulin 0 siblings, 1 reply; 6+ messages in thread From: Matthew Auld @ 2023-01-27 13:10 UTC (permalink / raw) To: Tvrtko Ursulin Cc: Rob Clark, Thomas Hellström, katrinzhou, intel-gfx, open list, dri-devel, Chris Wilson, Matthew Auld, Daniel Vetter, Rodrigo Vivi, David Airlie On Mon, 23 Jan 2023 at 16:57, Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> wrote: > > > + some more people based on e1a7ab4fca0c > > On 19/01/2023 17:32, Rob Clark wrote: > > From: Rob Clark <robdclark@chromium.org> > > > > 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. > > > > Signed-off-by: Rob Clark <robdclark@chromium.org> > > --- > > 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? Sorry for the delay. Fix looks good to me, Reviewed-by: Matthew Auld <matthew.auld@intel.com> Looking at the git history, the fixes tag I think needs to be: Fixes: 9ec8795e7d91 ("drm/i915: Drop __rcu from gem_context->vm") Cc: <stable@vger.kernel.org> # v5.16+ > > Regards, > > Tvrtko > > > > > drivers/gpu/drm/i915/gem/i915_gem_context.c | 14 +++++++++++--- > > 1 file changed, 11 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c > > index 6250de9b9196..e4b78ab4773b 100644 > > --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c > > +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c > > @@ -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; ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: Avoid potential vm use-after-free 2023-01-27 13:10 ` Matthew Auld @ 2023-01-27 13:50 ` Tvrtko Ursulin 0 siblings, 0 replies; 6+ messages in thread From: Tvrtko Ursulin @ 2023-01-27 13:50 UTC (permalink / raw) To: Matthew Auld Cc: Rob Clark, Thomas Hellström, katrinzhou, intel-gfx, open list, dri-devel, Chris Wilson, Matthew Auld, Daniel Vetter, Rodrigo Vivi, David Airlie On 27/01/2023 13:10, Matthew Auld wrote: > On Mon, 23 Jan 2023 at 16:57, Tvrtko Ursulin > <tvrtko.ursulin@linux.intel.com> wrote: >> >> >> + some more people based on e1a7ab4fca0c >> >> On 19/01/2023 17:32, Rob Clark wrote: >>> From: Rob Clark <robdclark@chromium.org> >>> >>> 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. >>> >>> Signed-off-by: Rob Clark <robdclark@chromium.org> >>> --- >>> 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? > > Sorry for the delay. Fix looks good to me, > Reviewed-by: Matthew Auld <matthew.auld@intel.com> > > Looking at the git history, the fixes tag I think needs to be: > > Fixes: 9ec8795e7d91 ("drm/i915: Drop __rcu from gem_context->vm") > Cc: <stable@vger.kernel.org> # 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. > >> >> Regards, >> >> Tvrtko >> >>> >>> drivers/gpu/drm/i915/gem/i915_gem_context.c | 14 +++++++++++--- >>> 1 file changed, 11 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c >>> index 6250de9b9196..e4b78ab4773b 100644 >>> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c >>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c >>> @@ -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; ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-01-27 13:50 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-01-19 17:32 [Intel-gfx] [PATCH] drm/i915: Avoid potential vm use-after-free Rob Clark 2023-01-19 18:42 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork 2023-01-20 22:03 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork 2023-01-23 16:56 ` [Intel-gfx] [PATCH] " Tvrtko Ursulin 2023-01-27 13:10 ` Matthew Auld 2023-01-27 13:50 ` Tvrtko Ursulin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox