drm/i915: Fixup userptr mmu notifier registration error handling
Subsystems (2)
PATCH 1/1 drm/i915: Fixup userptr mmu notifier registration error handling
One of the original patches got this right, but then in an attempt to make the error handling more correct it got worse. Try again.
The problem here is that we clear err to 0 when mm->mn != NULL, which will then leak the workqueue
--- drivers/gpu/drm/i915/i915_gem_userptr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_userptr.c +3 -1
@@ -209,8 +209,10 @@ i915_mmu_notifier_find(struct i915_mm_struct *mm)return mn; mn =i915_mmu_notifier_create (mm->mm); -if (IS_ERR (mn)) +if (IS_ERR (mn)) { err =PTR_ERR (mn); + mn =NULL ; + }down_write (&mm->mm->mmap_sem);mutex_lock (&mm->i915->mm_lock);
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Tvrtko Ursulin
maintainerPATCH v2 1/1 drm/i915: Fixup userptr mmu notifier registration error handling
From: Tvrtko Ursulin <[email protected]>
Avoid dereferencing the error pointer and also avoid returning NULL from i915_mmu_notifier_find since the callers do not expect that.
--- drivers/gpu/drm/i915/i915_gem_userptr.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_gem_userptr.c +6 -4
@@ -221,15 +221,17 @@ i915_mmu_notifier_find(struct i915_mm_struct *mm)/* Protected by mm_lock */ mm->mn =fetch_and_zero (&mn); } - }else { -/* someone else raced and successfully installed the mmu -* notifier, we can cancel our own errors */ + }else if (mm->mn) { +/* +* Someone else raced and successfully installed the mmu +* notifier, we can cancel our own errors. +*/ err =0 ; }mutex_unlock (&mm->i915->mm_lock);up_write (&mm->mm->mmap_sem); -if (mn) { +if (mn && !IS_ERR (mn)) {destroy_workqueue (mn->wq);kfree (mn); }
Signature · 6 lines
2.9.5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Tvrtko Ursulin (2017-10-17 16:09:08)
Quoted 23 lines
From: Tvrtko Ursulin <[email protected]>
Avoid dereferencing the error pointer and also avoid returning NULL from
i915_mmu_notifier_findsince the callers do not expect that.Signed-off-by Tvrtko Ursulin <[email protected]>Reported-by Dan Carpenter <[email protected]>Fixes 7741b547b6e0 ("drm/i915: Preallocate our mmu notifier workequeu to unbreak cpu hotplug deadlock")Cc Dan Carpenter <[email protected]>Cc Chris Wilson <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc Joonas Lahtinen <[email protected]>--- drivers/gpu/drm/i915/i915_gem_userptr.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/i915_gem_userptr.c +0
-0@@ -221,15 +221,17 @@ i915_mmu_notifier_find(struct i915_mm_struct *mm)/* Protected by mm_lock */ mm->mn =fetch_and_zero (&mn);
drivers/gpu/drm/i915/i915_gem_userptr.c i915_mmu_notifier_find(struct i915_mm_struct *mm) · line 229
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_userptr.c +5
-3} - }else { -/* someone else raced and successfully installed the mmu -* notifier, we can cancel our own errors */ + }else if (mm->mn) { +/* +* Someone else raced and successfully installed the mmu +* notifier, we can cancel our own errors. +*/ err =0 ;
residual else branch => err != 0 (i.e. mn is an ERR_PTR)
(Note that we could do
if (mm->mn) {
} else if (!IS_ERR(mn)) {
} else {
err = ERR_PTR(mn);
}just to have slightly more balanced branches; and is how I verified you have all bases covered.)
drivers/gpu/drm/i915/i915_gem_userptr.c i915_mmu_notifier_find(struct i915_mm_struct *mm) · line 234
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem_userptr.c +1
-1}mutex_unlock (&mm->i915->mm_lock);up_write (&mm->mm->mmap_sem); -if (mn) { +if (mn && !IS_ERR (mn)) {
Ok.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 4 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Avoid dereferencing the error pointer and also avoid returning NULL from
i915_mmu_notifier_findsince the callers do not expect that.
How did my patch return a NULL value? At least I assume that's the reasonf for your v2 ...
-Daniel
Quoted 45 lines
Signed-off-by Tvrtko Ursulin <[email protected]>Reported-by Dan Carpenter <[email protected]>Fixes 7741b547b6e0 ("drm/i915: Preallocate our mmu notifier workequeu to unbreak cpu hotplug deadlock")Cc Dan Carpenter <[email protected]>Cc Chris Wilson <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc Joonas Lahtinen <[email protected]>--- drivers/gpu/drm/i915/i915_gem_userptr.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/i915_gem_userptr.c +6
-4@@ -221,15 +221,17 @@ i915_mmu_notifier_find(struct i915_mm_struct *mm)/* Protected by mm_lock */ mm->mn =fetch_and_zero (&mn); } - }else { -/* someone else raced and successfully installed the mmu -* notifier, we can cancel our own errors */ + }else if (mm->mn) { +/* +* Someone else raced and successfully installed the mmu +* notifier, we can cancel our own errors. +*/ err =0 ; }mutex_unlock (&mm->i915->mm_lock);up_write (&mm->mm->mmap_sem); -if (mn) { +if (mn && !IS_ERR (mn)) {destroy_workqueue (mn->wq);kfree (mn); }Signature · 6 lines
2.9.5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 8 lines · Daniel Vetter
Quoted 4 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Avoid dereferencing the error pointer and also avoid returning NULL from
i915_mmu_notifier_findsince the callers do not expect that.How did my patch return a NULL value? At least I assume that's the reasonf for your v2 ...
The flow as I saw it was:
1. err = PTR_ERR
2. mn->mm == NULL
3. err = 0
4. return mm->mn
Which I okay-ed as well so a combined fail.
I pinged you on IRC and from your reply I understood you want me to send the patch I showed there, and don't want to bother thinking about it any longer.
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915: Fixup userptr mmu notifier registration error handling
In reply to Daniel Vetter== Series Details ==
== Series Details ==
Series: drm/i915: Fixup userptr mmu notifier registration error handling
URL : https://patchwork.freedesktop.org/series/32136/
State : success
== Summary ==
Series 32136v1 drm/i915: Fixup userptr mmu notifier registration error handling
https://patchwork.freedesktop.org/api/1.0/series/32136/revisions/1/mbox/
Test chamelium:
Subgroup dp-edid-read:
pass -> FAIL (fi-kbl-7500u) fdo#102672
Test kms_cursor_legacy:
Subgroup basic-busy-flip-before-cursor-legacy:
fail -> PASS (fi-gdg-551) fdo#102618
Subgroup basic-flip-after-cursor-varying-size:
skip -> PASS (fi-hsw-4770r)
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-b:
dmesg-warn -> PASS (fi-byt-n2820) fdo#101705fdo#102672 https://bugs.freedesktop.org/show_bug.cgi?id=102672
fdo#102618 https://bugs.freedesktop.org/show_bug.cgi?id=102618
fdo#101705 https://bugs.freedesktop.org/show_bug.cgi?id=101705
fi-bdw-5557u total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:443s fi-bdw-gvtdvm total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:454s fi-blb-e6850 total:289 pass:223 dwarn:1 dfail:0 fail:0 skip:65 time:372s fi-bsw-n3050 total:289 pass:243 dwarn:0 dfail:0 fail:0 skip:46 time:514s fi-bwr-2160 total:289 pass:183 dwarn:0 dfail:0 fail:0 skip:106 time:262s fi-bxt-dsi total:289 pass:259 dwarn:0 dfail:0 fail:0 skip:30 time:495s fi-bxt-j4205 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:494s fi-byt-j1900 total:289 pass:253 dwarn:1 dfail:0 fail:0 skip:35 time:487s fi-byt-n2820 total:289 pass:250 dwarn:0 dfail:0 fail:0 skip:39 time:481s fi-cfl-s total:289 pass:253 dwarn:4 dfail:0 fail:0 skip:32 time:553s fi-elk-e7500 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:418s fi-gdg-551 total:289 pass:178 dwarn:1 dfail:0 fail:1 skip:109 time:249s fi-glk-1 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:574s fi-hsw-4770r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:418s fi-ilk-650 total:289 pass:228 dwarn:0 dfail:0 fail:0 skip:61 time:431s fi-ivb-3520m total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:485s fi-ivb-3770 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:458s fi-kbl-7500u total:289 pass:263 dwarn:1 dfail:0 fail:1 skip:24 time:485s fi-kbl-7560u total:289 pass:270 dwarn:0 dfail:0 fail:0 skip:19 time:566s fi-kbl-7567u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:479s fi-kbl-r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:580s fi-pnv-d510 total:289 pass:222 dwarn:1 dfail:0 fail:0 skip:66 time:542s fi-skl-6260u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:449s fi-skl-6700hq total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:641s fi-skl-6700k total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:516s fi-skl-6770hq total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:495s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:453s fi-snb-2520m total:289 pass:250 dwarn:0 dfail:0 fail:0 skip:39 time:561s fi-snb-2600 total:289 pass:249 dwarn:0 dfail:0 fail:0 skip:40 time:416s
920fa3252916e0ec9da1df709744c568f621a43d drm-tip: 2017y-10m-17d-09h-45m-06s UTC integration manifest 9106dd9ce661 drm/i915: Fixup userptr mmu notifier registration error handling
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_6073/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915: Fixup userptr mmu notifier registration error handling (rev2)
In reply to Daniel Vetter== Series Details ==
== Series Details ==
Series: drm/i915: Fixup userptr mmu notifier registration error handling (rev2)
URL : https://patchwork.freedesktop.org/series/32136/
State : success
== Summary ==
Series 32136v2 drm/i915: Fixup userptr mmu notifier registration error handling
https://patchwork.freedesktop.org/api/1.0/series/32136/revisions/2/mbox/
Test kms_cursor_legacy:
Subgroup basic-busy-flip-before-cursor-legacy:
fail -> PASS (fi-gdg-551) fdo#102618
Subgroup basic-flip-after-cursor-varying-size:
skip -> PASS (fi-hsw-4770r)fdo#102618 https://bugs.freedesktop.org/show_bug.cgi?id=102618
fi-bdw-5557u total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:438s fi-bdw-gvtdvm total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:452s fi-blb-e6850 total:289 pass:223 dwarn:1 dfail:0 fail:0 skip:65 time:374s fi-bsw-n3050 total:289 pass:243 dwarn:0 dfail:0 fail:0 skip:46 time:539s fi-bwr-2160 total:289 pass:183 dwarn:0 dfail:0 fail:0 skip:106 time:264s fi-bxt-dsi total:289 pass:259 dwarn:0 dfail:0 fail:0 skip:30 time:498s fi-bxt-j4205 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:495s fi-byt-j1900 total:289 pass:253 dwarn:1 dfail:0 fail:0 skip:35 time:498s fi-byt-n2820 total:289 pass:249 dwarn:1 dfail:0 fail:0 skip:39 time:472s fi-cfl-s total:289 pass:253 dwarn:4 dfail:0 fail:0 skip:32 time:561s fi-elk-e7500 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:423s fi-gdg-551 total:289 pass:178 dwarn:1 dfail:0 fail:1 skip:109 time:250s fi-glk-1 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:575s fi-hsw-4770r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:423s fi-ilk-650 total:289 pass:228 dwarn:0 dfail:0 fail:0 skip:61 time:431s fi-ivb-3520m total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:481s fi-ivb-3770 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:460s fi-kbl-7500u total:289 pass:264 dwarn:1 dfail:0 fail:0 skip:24 time:488s fi-kbl-7560u total:289 pass:270 dwarn:0 dfail:0 fail:0 skip:19 time:571s fi-kbl-7567u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:473s fi-kbl-r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:583s fi-pnv-d510 total:289 pass:222 dwarn:1 dfail:0 fail:0 skip:66 time:544s fi-skl-6260u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:446s fi-skl-6700hq total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:646s fi-skl-6700k total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:522s fi-skl-6770hq total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:494s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:458s fi-snb-2520m total:289 pass:250 dwarn:0 dfail:0 fail:0 skip:39 time:561s fi-snb-2600 total:289 pass:249 dwarn:0 dfail:0 fail:0 skip:40 time:412s
920fa3252916e0ec9da1df709744c568f621a43d drm-tip: 2017y-10m-17d-09h-45m-06s UTC integration manifest a9f219b93a01 drm/i915: Fixup userptr mmu notifier registration error handling
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_6076/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: ✓ Fi.CI.BAT: success for drm/i915: Fixup userptr mmu notifier registration error handling (rev2)
Quoted 49 lines · Patchwork
== Series Details ==
Series: drm/i915: Fixup userptr mmu notifier registration error handling (rev2)
URL : https://patchwork.freedesktop.org/series/32136/
State : success== Summary ==
Series 32136v2 drm/i915: Fixup userptr mmu notifier registration error handling
https://patchwork.freedesktop.org/api/1.0/series/32136/revisions/2/mbox/Test
kms_cursor_legacy:Subgroup basic-busy-flip-before-cursor-legacy: fail -> PASS (fi-gdg-551) fdo#102618 Subgroup basic-flip-after-cursor-varying-size: skip -> PASS (fi-hsw-4770r)fdo#102618 https://bugs.freedesktop.org/show_bug.cgi?id=102618
fi-bdw-5557u total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:438s fi-bdw-gvtdvm total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:452s fi-blb-e6850 total:289 pass:223 dwarn:1 dfail:0 fail:0 skip:65 time:374s fi-bsw-n3050 total:289 pass:243 dwarn:0 dfail:0 fail:0 skip:46 time:539s fi-bwr-2160 total:289 pass:183 dwarn:0 dfail:0 fail:0 skip:106 time:264s fi-bxt-dsi total:289 pass:259 dwarn:0 dfail:0 fail:0 skip:30 time:498s fi-bxt-j4205 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:495s fi-byt-j1900 total:289 pass:253 dwarn:1 dfail:0 fail:0 skip:35 time:498s fi-byt-n2820 total:289 pass:249 dwarn:1 dfail:0 fail:0 skip:39 time:472s fi-cfl-s total:289 pass:253 dwarn:4 dfail:0 fail:0 skip:32 time:561s fi-elk-e7500 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:423s fi-gdg-551 total:289 pass:178 dwarn:1 dfail:0 fail:1 skip:109 time:250s fi-glk-1 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:575s fi-hsw-4770r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:423s fi-ilk-650 total:289 pass:228 dwarn:0 dfail:0 fail:0 skip:61 time:431s fi-ivb-3520m total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:481s fi-ivb-3770 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:460s fi-kbl-7500u total:289 pass:264 dwarn:1 dfail:0 fail:0 skip:24 time:488s fi-kbl-7560u total:289 pass:270 dwarn:0 dfail:0 fail:0 skip:19 time:571s fi-kbl-7567u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:473s fi-kbl-r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:583s fi-pnv-d510 total:289 pass:222 dwarn:1 dfail:0 fail:0 skip:66 time:544s fi-skl-6260u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:446s fi-skl-6700hq total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:646s fi-skl-6700k total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:522s fi-skl-6770hq total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:494s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:458s fi-snb-2520m total:289 pass:250 dwarn:0 dfail:0 fail:0 skip:39 time:561s fi-snb-2600 total:289 pass:249 dwarn:0 dfail:0 fail:0 skip:40 time:412s
Quoted 2 lines
920fa3252916e0ec9da1df709744c568f621a43ddrm-tip: 2017y-10m-17d-09h-45m-06s UTC integration manifesta9f219b93a01drm/i915: Fixup userptr mmu notifier registration error handling
Pushed, hopefully we managed to change the lightbulb now! :)
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.IGT: warning for drm/i915: Fixup userptr mmu notifier registration error handling (rev2)
In reply to Daniel Vetter== Series Details ==
== Series Details ==
Series: drm/i915: Fixup userptr mmu notifier registration error handling (rev2)
URL : https://patchwork.freedesktop.org/series/32136/
State : warning
== Summary ==
Test pm_rpm:
Subgroup fences:
pass -> SKIP (shard-hsw)
Test kms_cursor_crc:
Subgroup cursor-256x256-onscreen:
pass -> SKIP (shard-hsw)
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-pri-indfb-multidraw:
pass -> SKIP (shard-hsw)shard-hsw total:2553 pass:1436 dwarn:0 dfail:0 fail:11 skip:1106 time:9141s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_6076/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx