mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Bug report: mdp5_crtc.c: use-after-free bug in mdp5_crtc_destroy due to race condition
@ 2024-04-15  8:52 sicong
  0 siblings, 0 replies; only message in thread
From: sicong @ 2024-04-15  8:52 UTC (permalink / raw)
  To: robdclark, quic_abhinavk, dmitry.baryshkov, sean, airlied, daniel
  Cc: linux-arm-msm, linux-kernel



mdp5_crtc.c: use-after-free bug in mdp5_crtc_destroy due to race condition

In mdp5_crtc_init, &mdp5_crtc->unref_cursor_work is bound with 
unref_cursor_worker. This work will be commited by drm_flip_work_commit 
located in mdp5_crtc_vblank_irq.

If we call mdp5_crtc_destroy to make cleanup, there may be a unfinished work. 
This function will call drm_flip_work_cleanup to destroy resources allocated 
for the flip-work. However, drm_flip_work_cleanup works as following:
WARN_ON(!list_empty(&work->queued) || !list_empty(&work->commited));

After mdp5_crtc_destroy call kfree to release the object "mdp5_crtc", 
&mdp5_crtc->unref_cursor_work will get use-after-free error.

CPU 0                          	        CPU 1
                                           |	unref_cursor_worker
mdp5_crtc_destroy            |
kfree(mdp5_crtc)  (free)    |
                                           |	get_kms(&mdp5_crtc->base) (use)

This bug may be fixed by adding the following instructions in drm_flip_work_cleanup.
flush_work(&mdp5_crtc->unref_cursor_work)

Best regards,
Sicong Huang


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-15  8:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-15  8:52 Bug report: mdp5_crtc.c: use-after-free bug in mdp5_crtc_destroy due to race condition sicong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®