drm/i915: Fix a potential UAF at device unload
Subsystems (2)
PATCH 1/2 drm/i915: Fix a potential UAF at device unload
i915_gem_drain_freed_objects() might not be enough to free all the objects and RCU delayed work might get scheduled after the i915 device struct gets freed.
Call i915_gem_drain_workqueue() to catch all RCU delayed work.
--- drivers/gpu/drm/i915/i915_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -1254,7 +1254,7 @@ void i915_gem_init_early(struct drm_i915_private *dev_priv)void i915_gem_cleanup_early (struct drm_i915_private *dev_priv) { -i915_gem_drain_freed_objects (dev_priv); +i915_gem_drain_workqueue (dev_priv);GEM_BUG_ON (!llist_empty (&dev_priv->mm.free_list));GEM_BUG_ON (atomic_read (&dev_priv->mm.free_count));drm_WARN_ON (&dev_priv->drm, dev_priv->mm.shrink_count);
Signature · 1 line
2.37.3
PATCH 2/2 drm/i915: remove excessive i915_gem_drain_freed_objects
i915_gem_drain_workqueue() call i915_gem_drain_freed_objects() so no need to call that again.
--- drivers/gpu/drm/i915/i915_gem.c | 2 -- drivers/gpu/drm/i915/selftests/mock_gem_device.c | 1 - 2 files changed, 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +0 -2
@@ -1217,8 +1217,6 @@ void i915_gem_driver_remove(struct drm_i915_private *dev_priv)/* Flush any outstanding unpin_work. */ i915_gem_drain_workqueue (dev_priv); - -i915_gem_drain_freed_objects (dev_priv); }void i915_gem_driver_release (struct drm_i915_private *dev_priv)
drivers/gpu/drm/i915/selftests/mock_gem_device.c +0 -1
@@ -67,7 +67,6 @@ static void mock_device_release(struct drm_device *dev)intel_gt_driver_remove (to_gt (i915));i915_gem_drain_workqueue (i915); -i915_gem_drain_freed_objects (i915);mock_fini_ggtt (to_gt (i915)->ggtt);destroy_workqueue (i915->wq);
Signature · 1 line
2.37.3
Re: [Intel-gfx] [PATCH 2/2] drm/i915: remove excessive i915_gem_drain_freed_objects
Quoted 27 lines · Nirmoy Das
i915_gem_drain_workqueue()calli915_gem_drain_freed_objects()so no need to call that again.Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 2 -- drivers/gpu/drm/i915/selftests/mock_gem_device.c | 1 - 2 files changed, 3 deletions(-)drivers/gpu/drm/i915/i915_gem.c +0
-2@@ -1217,8 +1217,6 @@ void i915_gem_driver_remove(struct drm_i915_private *dev_priv)/* Flush any outstanding unpin_work. */ i915_gem_drain_workqueue (dev_priv); - -i915_gem_drain_freed_objects (dev_priv); }void i915_gem_driver_release (struct drm_i915_private *dev_priv)drivers/gpu/drm/i915/selftests/mock_gem_device.c +0
-0
drivers/gpu/drm/i915/selftests/mock_gem_device.c static void mock_device_release(struct drm_device *dev) · line 72
Quoted 7 lines
drivers/gpu/drm/i915/selftests/mock_gem_device.c +0
-1@@ -67,7 +67,6 @@ static void mock_device_release(struct drm_device *dev)intel_gt_driver_remove (to_gt (i915));i915_gem_drain_workqueue (i915); -i915_gem_drain_freed_objects (i915);mock_fini_ggtt (to_gt (i915)->ggtt);destroy_workqueue (i915->wq);
Regards,
Tvrtko
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [1/2] drm/i915: Fix a potential UAF at device unload
In reply to Nirmoy Das== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/i915: Fix a potential UAF at device unload
URL : https://patchwork.freedesktop.org/series/108314/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_12100 -> Patchwork_108314v1
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_108314v1 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_108314v1, 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_108314v1/index.html
Participating hosts (42 -> 41)
------------------------------
Missing (1): fi-bdw-samus
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_108314v1:
### IGT changes ###
#### Possible regressions ####
* igt@i915_selftest@live@mman:
- fi-rkl-guc: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12100/fi-rkl-guc/igt@i915_selftest@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/fi-rkl-guc/igt@i915_selftest@[email protected]
Known issues
------------
Here are the changes found in Patchwork_108314v1 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_selftest@live@hangcheck:
- fi-hsw-g3258: [PASS][3] -> [INCOMPLETE][4] ([i915#3303] / [i915#4785])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12100/fi-hsw-g3258/igt@i915_selftest@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/fi-hsw-g3258/igt@i915_selftest@[email protected]
- bat-dg1-5: NOTRUN -> [DMESG-FAIL][5] ([i915#4494] / [i915#4957])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/bat-dg1-5/igt@i915_selftest@[email protected]
- fi-snb-2600: [PASS][6] -> [INCOMPLETE][7] ([i915#3921])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12100/fi-snb-2600/igt@i915_selftest@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/fi-snb-2600/igt@i915_selftest@[email protected]
* igt@i915_suspend@basic-s2idle-without-i915:
- bat-dg1-5: NOTRUN -> [INCOMPLETE][8] ([i915#6011])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/bat-dg1-5/igt@[email protected]
* igt@kms_chamelium@common-hpd-after-suspend:
- fi-hsw-4770: NOTRUN -> [SKIP][9] ([fdo#109271] / [fdo#111827])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/fi-hsw-4770/igt@[email protected]
- fi-blb-e6850: NOTRUN -> [SKIP][10] ([fdo#109271])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/fi-blb-e6850/igt@[email protected]
* igt@runner@aborted:
- fi-hsw-g3258: NOTRUN -> [FAIL][11] ([fdo#109271] / [i915#4312] / [i915#6246])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/fi-hsw-g3258/igt@[email protected]
#### Possible fixes ####
* igt@i915_selftest@live@gem:
- fi-blb-e6850: [DMESG-FAIL][12] ([i915#4528]) -> [PASS][13]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12100/fi-blb-e6850/igt@i915_selftest@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/fi-blb-e6850/igt@i915_selftest@[email protected]
* igt@i915_selftest@live@gt_engines:
- bat-dg1-5: [INCOMPLETE][14] ([i915#4418]) -> [PASS][15]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12100/bat-dg1-5/igt@i915_selftest@live@gt_engines.html
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/bat-dg1-5/igt@i915_selftest@live@gt_engines.html
* igt@i915_selftest@live@hangcheck:
- fi-hsw-4770: [INCOMPLETE][16] ([i915#4785]) -> [PASS][17]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12100/fi-hsw-4770/igt@i915_selftest@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/fi-hsw-4770/igt@i915_selftest@[email protected]
* igt@kms_chamelium@common-hpd-after-suspend:
- fi-skl-6700k2: [INCOMPLETE][18] ([i915#6598]) -> [PASS][19]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12100/fi-skl-6700k2/igt@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/fi-skl-6700k2/igt@[email protected]
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor@atomic-transitions-varying-size:
- fi-bsw-kefka: [FAIL][20] ([i915#6298]) -> [PASS][21]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12100/fi-bsw-kefka/igt@kms_cursor_legacy@basic-busy-flip-before-cursor@atomic-transitions-varying-size.html
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/fi-bsw-kefka/igt@kms_cursor_legacy@basic-busy-flip-before-cursor@atomic-transitions-varying-size.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
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#2867]: https://gitlab.freedesktop.org/drm/intel/issues/2867
[i915#3303]: https://gitlab.freedesktop.org/drm/intel/issues/3303
[i915#3921]: https://gitlab.freedesktop.org/drm/intel/issues/3921
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4418]: https://gitlab.freedesktop.org/drm/intel/issues/4418
[i915#4494]: https://gitlab.freedesktop.org/drm/intel/issues/4494
[i915#4528]: https://gitlab.freedesktop.org/drm/intel/issues/4528
[i915#4785]: https://gitlab.freedesktop.org/drm/intel/issues/4785
[i915#4957]: https://gitlab.freedesktop.org/drm/intel/issues/4957
[i915#6011]: https://gitlab.freedesktop.org/drm/intel/issues/6011
[i915#6246]: https://gitlab.freedesktop.org/drm/intel/issues/6246
[i915#6298]: https://gitlab.freedesktop.org/drm/intel/issues/6298
[i915#6598]: https://gitlab.freedesktop.org/drm/intel/issues/6598
Build changes
-------------
* Linux: CI_DRM_12100 -> Patchwork_108314v1
CI-20190529: 20190529
CI_DRM_12100: 97f3651d0cd43a46f8065e7f64107f76bb9f704b @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6648: 3c9079c0b97445fbfc903b9c5a1d69707b80af80 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_108314v1: 97f3651d0cd43a46f8065e7f64107f76bb9f704b @ git://anongit.freedesktop.org/gfx-ci/linux
### Linux commits
1ddcab3bf382 drm/i915: remove excessive i915_gem_drain_freed_objects b9c37f3555af drm/i915: Fix a potential UAF at device unload
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108314v1/index.html
Quoted 17 lines · Nirmoy Das
i915_gem_drain_freed_objects()might not be enough to free all the objects and RCU delayed work might get scheduled after the i915 device struct gets freed.Call
i915_gem_drain_workqueue()to catch all RCU delayed work.Suggested-by Chris Wilson <[email protected]>Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/i915_gem.c +0
-0
drivers/gpu/drm/i915/i915_gem.c void i915_gem_init_early(struct drm_i915_private *dev_priv) · line 1260
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem.c +1
-1@@ -1254,7 +1254,7 @@ void i915_gem_init_early(struct drm_i915_private *dev_priv)void i915_gem_cleanup_early (struct drm_i915_private *dev_priv) { -i915_gem_drain_freed_objects (dev_priv); +i915_gem_drain_workqueue (dev_priv);GEM_BUG_ON (!llist_empty (&dev_priv->mm.free_list));GEM_BUG_ON (atomic_read (&dev_priv->mm.free_count));drm_WARN_ON (&dev_priv->drm, dev_priv->mm.shrink_count);
Help me spot the place where RCU free worker schedules itself back to free more objects - if I got the rationale here right?
Regards,
Tvrtko
Quoted 14 lines · Tvrtko Ursulin
Quoted 12 lines · Nirmoy Das
i915_gem_drain_freed_objects()might not be enough to free all the objects and RCU delayed work might get scheduled after the i915 device struct gets freed.Call
i915_gem_drain_workqueue()to catch all RCU delayed work.Suggested-by Chris Wilson <[email protected]>Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/i915/i915_gem.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
drivers/gpu/drm/i915/i915_gem.c void i915_gem_init_early(struct · line 1260
Quoted 13 lines
drivers/gpu/drm/i915/i915_gem.c +1
-1@@ -1254,7 +1254,7 @@ void i915_gem_init_early(struct drm_i915_private *dev_priv) void i915_gem_cleanup_early(struct drm_i915_private *dev_priv) { - i915_gem_drain_freed_objects(dev_priv); + i915_gem_drain_workqueue(dev_priv); GEM_BUG_ON(!llist_empty(&dev_priv->mm.free_list)); GEM_BUG_ON(atomic_read(&dev_priv->mm.free_count)); drm_WARN_ON(&dev_priv->drm, dev_priv->mm.shrink_count);Help me spot the place where RCU free worker schedules itself back to free more objects - if I got the rationale here right?
(Sorry for late reply, was on leave last week.)
I had to clarify this with Chris. So when driver frees a obj, it does dma_resv_fini() which will drop reference
for all the fences in it and a fence might reference to an object and upon release of that fence can trigger a release reference to an object.
Regards,
Nirmoy
Quoted 4 lines
Regards,
Tvrtko
Quoted 32 lines · Nirmoy
Quoted 14 lines · Tvrtko Ursulin
Quoted 12 lines · Nirmoy Das
i915_gem_drain_freed_objects()might not be enough to free all the objects and RCU delayed work might get scheduled after the i915 device struct gets freed.Call
i915_gem_drain_workqueue()to catch all RCU delayed work.Suggested-by Chris Wilson <[email protected]>Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/i915/i915_gem.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)Quoted 16 lines
drivers/gpu/drm/i915/i915_gem.c void i915_gem_init_early(struct · line 1260
Quoted 13 lines
drivers/gpu/drm/i915/i915_gem.c +1
-1@@ -1254,7 +1254,7 @@ void i915_gem_init_early(struct drm_i915_private *dev_priv) void i915_gem_cleanup_early(struct drm_i915_private *dev_priv) { - i915_gem_drain_freed_objects(dev_priv); + i915_gem_drain_workqueue(dev_priv); GEM_BUG_ON(!llist_empty(&dev_priv->mm.free_list)); GEM_BUG_ON(atomic_read(&dev_priv->mm.free_count)); drm_WARN_ON(&dev_priv->drm, dev_priv->mm.shrink_count);Help me spot the place where RCU free worker schedules itself back to free more objects - if I got the rationale here right?
Quoted 5 lines
(Sorry for late reply, was on leave last week.)
I had to clarify this with Chris. So when driver frees a obj, it does
dma_resv_fini()which will drop referencefor all the fences in it and a fence might reference to an object and upon release of that fence can trigger a release reference to an object.
Hmm I couldn't find that in code but never mind. It's just a stronger version of the same flushing and it's not on a path where speed matters so feel free to go with it.
Regards,
Tvrtko
Quoted 34 lines · Tvrtko Ursulin
Quoted 32 lines · Nirmoy
Quoted 30 lines · Tvrtko Ursulin
Quoted 17 lines · Nirmoy Das
i915_gem_drain_freed_objects()might not be enough to free all the objects and RCU delayed work might get scheduled after the i915 device struct gets freed.Call
i915_gem_drain_workqueue()to catch all RCU delayed work.Suggested-by Chris Wilson <[email protected]>Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/i915/i915_gem.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/i915_gem.c +0
-0drivers/gpu/drm/i915/i915_gem.c void i915_gem_init_early(struct · line 1260
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem.c +1
-1@@ -1254,7 +1254,7 @@ void i915_gem_init_early(struct drm_i915_private *dev_priv) void i915_gem_cleanup_early(struct drm_i915_private *dev_priv) { - i915_gem_drain_freed_objects(dev_priv); + i915_gem_drain_workqueue(dev_priv);GEM_BUG_ON (!llist_empty (&dev_priv->mm.free_list));GEM_BUG_ON (atomic_read (&dev_priv->mm.free_count)); drm_WARN_ON(&dev_priv->drm, dev_priv->mm.shrink_count);Help me spot the place where RCU free worker schedules itself back to free more objects - if I got the rationale here right?
Quoted 7 lines
Quoted 5 lines
(Sorry for late reply, was on leave last week.)
I had to clarify this with Chris. So when driver frees a obj, it does
dma_resv_fini()which will drop referencefor all the fences in it and a fence might reference to an object and upon release of that fence can trigger a release reference to an object.
Hmm I couldn't find that in code but never mind. It's just a stronger version of the same flushing and it's not on a path where speed matters so feel free to go with it.
Can I get a Ack from you for this, Tvrtko ?
Thanks,
Nirmoy
Quoted 4 lines
Regards,
Tvrtko
Tvrtko Ursulin
Acked-byQuoted 38 lines · Nirmoy
Quoted 36 lines · Tvrtko Ursulin
Quoted 34 lines · Nirmoy
Quoted 14 lines · Tvrtko Ursulin
Quoted 12 lines · Nirmoy Das
i915_gem_drain_freed_objects()might not be enough to free all the objects and RCU delayed work might get scheduled after the i915 device struct gets freed.Call
i915_gem_drain_workqueue()to catch all RCU delayed work.Suggested-by Chris Wilson <[email protected]>Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/i915/i915_gem.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)Quoted 16 lines
drivers/gpu/drm/i915/i915_gem.c void i915_gem_init_early(struct · line 1260
Quoted 13 lines
drivers/gpu/drm/i915/i915_gem.c +1
-1@@ -1254,7 +1254,7 @@ void i915_gem_init_early(struct drm_i915_private *dev_priv) void i915_gem_cleanup_early(struct drm_i915_private *dev_priv) { - i915_gem_drain_freed_objects(dev_priv); + i915_gem_drain_workqueue(dev_priv);GEM_BUG_ON (!llist_empty (&dev_priv->mm.free_list));GEM_BUG_ON (atomic_read (&dev_priv->mm.free_count)); drm_WARN_ON(&dev_priv->drm, dev_priv->mm.shrink_count);Help me spot the place where RCU free worker schedules itself back to free more objects - if I got the rationale here right?
(Sorry for late reply, was on leave last week.)
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I had to clarify this with Chris. So when driver frees a obj, it does
dma_resv_fini()which will drop referencefor all the fences in it and a fence might reference to an object and upon release of that fence can trigger a release reference to an object.
Hmm I couldn't find that in code but never mind. It's just a stronger version of the same flushing and it's not on a path where speed matters so feel free to go with it.
Can I get a Ack from you for this, Tvrtko ?
Sorry yes, forgot to be explicit.
Regards,
Tvrtko
Quoted 44 lines · Tvrtko Ursulin
Quoted 42 lines · Nirmoy
Quoted 40 lines · Tvrtko Ursulin
Quoted 37 lines · Nirmoy
Quoted 14 lines · Tvrtko Ursulin
Quoted 12 lines · Nirmoy Das
i915_gem_drain_freed_objects()might not be enough to free all the objects and RCU delayed work might get scheduled after the i915 device struct gets freed.Call
i915_gem_drain_workqueue()to catch all RCU delayed work.Suggested-by Chris Wilson <[email protected]>Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/i915/i915_gem.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)Quoted 16 lines
drivers/gpu/drm/i915/i915_gem.c void i915_gem_init_early(struct · line 1260
Quoted 13 lines
drivers/gpu/drm/i915/i915_gem.c +1
-1@@ -1254,7 +1254,7 @@ void i915_gem_init_early(struct drm_i915_private *dev_priv) void i915_gem_cleanup_early(struct drm_i915_private *dev_priv) { - i915_gem_drain_freed_objects(dev_priv); + i915_gem_drain_workqueue(dev_priv);GEM_BUG_ON (!llist_empty (&dev_priv->mm.free_list));GEM_BUG_ON (atomic_read (&dev_priv->mm.free_count)); drm_WARN_ON(&dev_priv->drm, dev_priv->mm.shrink_count);Help me spot the place where RCU free worker schedules itself back to free more objects - if I got the rationale here right?
(Sorry for late reply, was on leave last week.)
I had to clarify this with Chris. So when driver frees a obj, it does
dma_resv_fini()which will drop referencefor all the fences in it and a fence might reference to an object and upon release of that fence can trigger a release reference to an object.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Hmm I couldn't find that in code but never mind. It's just a stronger version of the same flushing and it's not on a path where speed matters so feel free to go with it.
Can I get a Ack from you for this, Tvrtko ?
Sorry yes, forgot to be explicit.
Acked-by Tvrtko Ursulin <[email protected]>
Thanks a lot. I will rebase and send again.
Nirmoy
Quoted 4 lines
Regards,
Tvrtko