Skip to contentSkip to conversation

drm/i915/ttm: ensure we release the intel_memory_region

PATCH In review Matthew Auld 4 participants 4 messages Aug 18, 2021 – Aug 19, 2021

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

PATCH 1/1 drm/i915/ttm: ensure we release the intel_memory_region

If the ttm_bo_init_reserved() call fails ensure we also release the region, otherwise we leak the reference, or worse hit some uaf, when we start using the objects.list. Also remove the make_unshrinkable call here, which doesn't do anything.

Cc Thomas Hellström <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +5 -2
index 771eb2963123..2e8cdcd5e4f7 100644
@@ -909,7 +909,6 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,
 	drm_gem_private_object_init(&i915->drm, &obj->base, size);
 	i915_gem_object_init(obj, &i915_gem_ttm_obj_ops, &lock_class, flags);
 	i915_gem_object_init_memory_region(obj, mem);
-	i915_gem_object_make_unshrinkable(obj);
 	INIT_RADIX_TREE(&obj->ttm.get_io_page.radix, GFP_KERNEL | __GFP_NOWARN);
 	mutex_init(&obj->ttm.get_io_page.lock);
 	bo_type = (obj->flags & I915_BO_ALLOC_USER) ? ttm_bo_type_device :
@@ -932,7 +931,7 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,
 				   page_size >> PAGE_SHIFT,
 				   &ctx, NULL, NULL, i915_ttm_bo_destroy);
 	if (ret)
-		return i915_ttm_err_to_gem(ret);
+		goto err_release_mr;
 
 	obj->ttm.created = true;
 	i915_ttm_adjust_domains_after_move(obj);
@@ -940,6 +939,10 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,
 	i915_gem_object_unlock(obj);
 
 	return 0;
+
+err_release_mr:
+	i915_gem_object_release_memory_region(obj);
+	return i915_ttm_err_to_gem(ret);
 }
 
 static const struct intel_memory_region_ops ttm_system_region_ops = {
Signature · 1 line
2.26.3
#1 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/ttm: ensure we release the intel_memory_region

== Series Details ==

== Series Details ==

Series: drm/i915/ttm: ensure we release the intel_memory_region
URL : https://patchwork.freedesktop.org/series/93791/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_10496 -> Patchwork_20848
====================================================

Summary
-------

**FAILURE**

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

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

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

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

### IGT changes ###

#### Possible regressions ####

* igt@i915_pm_rpm@module-reload:
- fi-tgl-1115g4: NOTRUN -> [INCOMPLETE][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20848/fi-tgl-1115g4/igt@[email protected]

* igt@kms_addfb_basic@too-wide:
- fi-tgl-1115g4: NOTRUN -> [DMESG-WARN][2] +89 similar issues
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20848/fi-tgl-1115g4/igt@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@amdgpu/amd_cs_nop@sync-fork-compute0:
- fi-kbl-soraka: NOTRUN -> [SKIP][3] ([fdo#109271]) +8 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20848/fi-kbl-soraka/igt@amdgpu/[email protected]

* igt@core_hotunplug@unbind-rebind:
- fi-tgl-1115g4: NOTRUN -> [DMESG-WARN][4] ([i915#1982])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20848/fi-tgl-1115g4/igt@[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-tgl-1115g4: NOTRUN -> [SKIP][5] ([i915#2190])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20848/fi-tgl-1115g4/igt@[email protected]

* igt@i915_pm_backlight@basic-brightness:
- fi-tgl-1115g4: NOTRUN -> [SKIP][6] ([i915#1155])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20848/fi-tgl-1115g4/igt@[email protected]

* igt@kms_chamelium@common-hpd-after-suspend:
- fi-tgl-1115g4: NOTRUN -> [SKIP][7] ([fdo#111827]) +8 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20848/fi-tgl-1115g4/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- fi-tgl-1115g4: NOTRUN -> [SKIP][8] ([fdo#109285])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20848/fi-tgl-1115g4/igt@[email protected]

* igt@kms_psr@primary_mmap_gtt:
- fi-tgl-1115g4: NOTRUN -> [SKIP][9] ([i915#1072]) +3 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20848/fi-tgl-1115g4/igt@kms_psr@primary_mmap_gtt.html

* igt@prime_vgem@basic-userptr:
- fi-tgl-1115g4: NOTRUN -> [SKIP][10] ([i915#3301])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20848/fi-tgl-1115g4/igt@[email protected]

* igt@runner@aborted:
- fi-bdw-5557u: NOTRUN -> [FAIL][11] ([i915#1602] / [i915#2029])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20848/fi-bdw-5557u/igt@[email protected]
- fi-tgl-1115g4: NOTRUN -> [FAIL][12] ([i915#2722] / [i915#3834])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20848/fi-tgl-1115g4/igt@[email protected]

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1155]: https://gitlab.freedesktop.org/drm/intel/issues/1155
[i915#1602]: https://gitlab.freedesktop.org/drm/intel/issues/1602
[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#2029]: https://gitlab.freedesktop.org/drm/intel/issues/2029
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2722]: https://gitlab.freedesktop.org/drm/intel/issues/2722
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#3834]: https://gitlab.freedesktop.org/drm/intel/issues/3834

Participating hosts (34 -> 34)
------------------------------

Additional (1): fi-tgl-1115g4
Missing (1): fi-bsw-cyan

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

* Linux: CI_DRM_10496 -> Patchwork_20848

CI-20190529: 20190529
CI_DRM_10496: e4f0d7fe9eeff06828925fc08a58a0084a205e50 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6178: 146260200f9a6d4536e48a195e2ab49a07d4f0c1 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_20848: fa8be4d952ec47c853afa2d424d137abe8584d5e @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

fa8be4d952ec drm/i915/ttm: ensure we release the intel_memory_region

== Logs ==

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

#2 lore raw
In reply to Matthew Auld
Quoted 30 lines · Matthew Auld

If the ttm_bo_init_reserved() call fails ensure we also release the region, otherwise we leak the reference, or worse hit some uaf, when we
start using the objects.list. Also remove the make_unshrinkable call here, which doesn't do anything.

Cc Thomas Hellström <[email protected]>

---
 drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 7 +++++--

 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -1
index 771eb2963123..2e8cdcd5e4f7 100644
@@ -909,7 +909,6 @@ int __i915_gem_ttm_object_init(struct
 intel_memory_region *mem,
         drm_gem_private_object_init(&i915->drm, &obj->base, size);
         i915_gem_object_init(obj, &i915_gem_ttm_obj_ops, &lock_class,
 flags);
         i915_gem_object_init_memory_region(obj, mem);
-       i915_gem_object_make_unshrinkable(obj);

        INIT_RADIX_TREE(&obj->ttm.get_io_page.radix, GFP_KERNEL | __GFP_NOWARN);
        mutex_init(&obj->ttm.get_io_page.lock);
        bo_type = (obj->flags & I915_BO_ALLOC_USER) ? ttm_bo_type_device :

drivers/gpu/drm/i915/gem/i915_gem_ttm.c int __i915_gem_ttm_object_init(struct · line 936

Quoted 7 lines
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1 -1
@@ -932,7 +931,7 @@ int __i915_gem_ttm_object_init(struct
 intel_memory_region *mem,
                                    page_size >> PAGE_SHIFT,
                                    &ctx, NULL, NULL,
 i915_ttm_bo_destroy);
         if (ret)
-               return i915_ttm_err_to_gem(ret);
+               goto err_release_mr;

IIRC when ttm_object_init_reserved fails, it will call ttm_bo_put() which will eventually end up in i915_ttm_bo_destroy() which will do the right thing?

/Thomas

#3 lore raw
Quoted 35 lines · Thomas Hellström
Quoted 33 lines · Matthew Auld

If the ttm_bo_init_reserved() call fails ensure we also release the region, otherwise we leak the reference, or worse hit some uaf, when we
start using the objects.list. Also remove the make_unshrinkable call here, which doesn't do anything.

Cc Thomas Hellström <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -1
index 771eb2963123..2e8cdcd5e4f7 100644
@@ -909,7 +909,6 @@ int __i915_gem_ttm_object_init(struct
 intel_memory_region *mem,
        drm_gem_private_object_init(&i915->drm, &obj->base, size);
        i915_gem_object_init(obj, &i915_gem_ttm_obj_ops, &lock_class,
 flags);
        i915_gem_object_init_memory_region(obj, mem);
-       i915_gem_object_make_unshrinkable(obj);
        INIT_RADIX_TREE(&obj->ttm.get_io_page.radix, GFP_KERNEL |
__GFP_NOWARN);
        mutex_init(&obj->ttm.get_io_page.lock);
        bo_type = (obj->flags & I915_BO_ALLOC_USER) ?

ttm_bo_type_device :

drivers/gpu/drm/i915/gem/i915_gem_ttm.c +0 -0
@@ -932,7 +931,7 @@ int __i915_gem_ttm_object_init(struct
 intel_memory_region *mem,
                                   page_size >> PAGE_SHIFT,
                                   &ctx, NULL, NULL,
Quoted 8 lines

drivers/gpu/drm/i915/gem/i915_gem_ttm.c int __i915_gem_ttm_object_init(struct intel_memory_region *mem, · line 934

Quoted 4 lines
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1 -1
 i915_ttm_bo_destroy);
        if (ret)
-               return i915_ttm_err_to_gem(ret);
+               goto err_release_mr;

IIRC when ttm_object_init_reserved fails, it will call ttm_bo_put() which will eventually end up in i915_ttm_bo_destroy() which will do the right thing?

Ah right, missed that.

Quoted 4 lines

/Thomas