Skip to contentSkip to conversation

drm/i915: fix use after free during eDP encoder destroying

PATCH Applied Imre Deak 5 participants 5 messages Dec 12, 2014 – Dec 16, 2014

Subsystems (2)
lore
Share & tools
lore

Imre Deak

author
#0 lore raw

PATCH 1/1 drm/i915: fix use after free during eDP encoder destroying

After

commit a18c0af171bfb875012da26f23df051004726973
uthor: Thierry Reding <[email protected]>
Date: Wed Dec 10 11:38:49 2014 +0100

drm: Zero out DRM object memory upon cleanup

we will use the eDP encoder during destroying it. Fix this by calling drm_encoder_cleanup() at a point when the encoder is not used any more. This caused a NULL pointer dereference in pps_lock(), I can't see that it caused any other problem.

All the other encoders seem to call drm_encoder_cleanup() at a safe place.

---
 drivers/gpu/drm/i915/intel_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp.c +1 -1
index 3fc3296..0a55623 100644
@@ -4310,7 +4310,6 @@ void intel_dp_encoder_destroy(struct drm_encoder *encoder)
 
 	drm_dp_aux_unregister(&intel_dp->aux);
 	intel_dp_mst_encoder_cleanup(intel_dig_port);
-	drm_encoder_cleanup(encoder);
 	if (is_edp(intel_dp)) {
 		cancel_delayed_work_sync(&intel_dp->panel_vdd_work);
 		/*
@@ -4326,6 +4325,7 @@ void intel_dp_encoder_destroy(struct drm_encoder *encoder)
 			intel_dp->edp_notifier.notifier_call = NULL;
 		}
 	}
+	drm_encoder_cleanup(encoder);
 	kfree(intel_dig_port);
 }
 
Signature · 6 lines
1.8.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Imre Deak

After

commit a18c0af171bfb875012da26f23df051004726973
uthor: Thierry Reding <[email protected]>
Date: Wed Dec 10 11:38:49 2014 +0100

drm: Zero out DRM object memory upon cleanup

we will use the eDP encoder during destroying it. Fix this by calling drm_encoder_cleanup() at a point when the encoder is not used any more. This caused a NULL pointer dereference in pps_lock(), I can't see that it caused any other problem.

Quoted 4 lines

All the other encoders seem to call drm_encoder_cleanup() at a safe place.

drm_encoder_cleanup() doesn't appear to have any nasty side effects so this looks sane.

Quoted 31 lines
---
 drivers/gpu/drm/i915/intel_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp.c +1 -1
index 3fc3296..0a55623 100644
@@ -4310,7 +4310,6 @@ void intel_dp_encoder_destroy(struct drm_encoder *encoder)
 
 	drm_dp_aux_unregister(&intel_dp->aux);
 	intel_dp_mst_encoder_cleanup(intel_dig_port);
-	drm_encoder_cleanup(encoder);
 	if (is_edp(intel_dp)) {
 		cancel_delayed_work_sync(&intel_dp->panel_vdd_work);
 		/*
@@ -4326,6 +4325,7 @@ void intel_dp_encoder_destroy(struct drm_encoder *encoder)
 			intel_dp->edp_notifier.notifier_call = NULL;
 		}
 	}
+	drm_encoder_cleanup(encoder);
 	kfree(intel_dig_port);
 }
 
Signature · 6 lines
1.8.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 8 lines · Ville Syrjälä
Quoted 7 lines · Imre Deak

After

commit a18c0af171bfb875012da26f23df051004726973
uthor: Thierry Reding <[email protected]>
Date: Wed Dec 10 11:38:49 2014 +0100

drm: Zero out DRM object memory upon cleanup

Please cc Thierry next time around. I've added him.

Quoted 9 lines
Quoted 9 lines

we will use the eDP encoder during destroying it. Fix this by calling drm_encoder_cleanup() at a point when the encoder is not used any more. This caused a NULL pointer dereference in pps_lock(), I can't see that it caused any other problem.

All the other encoders seem to call drm_encoder_cleanup() at a safe place.

Quoted 6 lines
Quoted 1 line

drm_encoder_cleanup() doesn't appear to have any nasty side effects so this looks sane.

Queued for -next, thanks for the patch.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by
#3 lore raw
Quoted 11 lines · Daniel Vetter
Quoted 8 lines · Ville Syrjälä
Quoted 7 lines · Imre Deak

After

commit a18c0af171bfb875012da26f23df051004726973
uthor: Thierry Reding <[email protected]>
Date: Wed Dec 10 11:38:49 2014 +0100

drm: Zero out DRM object memory upon cleanup

Please cc Thierry next time around. I've added him.

I don't have a copy of the original patch in any of my inboxes. It'd be nice to Cc [email protected] on patches of this nature.

I had to go dig for the patch in the intel-gfx archives and it looks good to me, so if it's not too late yet:

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Tested-by on v1 1/1
#4 lore raw
In reply to Imre Deak

-------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied
PNV 364/364 364/364
ILK +3-3 362/366 362/366
SNB 448/450 448/450
IVB -1 497/498 496/498

BYT                                  289/289              289/289
HSW                                  563/564              563/564
BDW                                  417/417              417/417
-------------------------------------Detailed-------------------------------------
Platform  Test                                drm-intel-nightly          Series Applied
 ILK  igt_kms_flip_nonexisting-fb      DMESG_WARN(1, M26)PASS(3, M37M26)      PASS(1, M26)
 ILK  igt_kms_flip_rcs-flip-vs-panning-interruptible      DMESG_WARN(1, M26)PASS(3, M37M26)      PASS(1, M26)
 ILK  igt_kms_flip_rcs-wf_vblank-vs-dpms-interruptible      DMESG_WARN(1, M26)PASS(2, M26M37)      PASS(1, M26)
 ILK  igt_kms_flip_busy-flip-interruptible      DMESG_WARN(1, M26)PASS(1, M26)      DMESG_WARN(1, M26)
*ILK  igt_kms_flip_rcs-flip-vs-panning      PASS(2, M26)      DMESG_WARN(1, M26)
*ILK  igt_kms_flip_vblank-vs-hang      PASS(2, M26)      NSPT(1, M26)
*IVB  igt_kms_cursor_crc_cursor-256x256-offscreen      PASS(2, M4M21)      DMESG_WARN(1, M21)

Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx