* [BUG] block: drbd: possible deadlocks involving waiting and locking operations
@ 2022-02-08 10:55 Jia-Ju Bai
0 siblings, 0 replies; only message in thread
From: Jia-Ju Bai @ 2022-02-08 10:55 UTC (permalink / raw)
To: philipp.reisner, lars.ellenberg, axboe
Cc: drbd-dev, linux-block, linux-kernel
Hello,
My static analysis tool reports three possible deadlocks in the drbd
driver in Linux 5.16:
#BUG 1
drbd_adm_attach()
mutex_lock(&adm_ctx.resource->adm_mutex); --> Line 1810 (Lock A)
wait_event(device->misc_wait, ...); --> Line 1824 (Wait X)
drbd_adm_disk_opts()
mutex_lock(&adm_ctx.resource->adm_mutex); --> Line 1582 (Lock A)
get_ldev()
get_ldev_if_state()
_get_ldev_if_state()
put_ldev()
wake_up(&device->misc_wait); --> Line 2108 (Wake X)
#BUG 2
drbd_adm_invalidate()
mutex_lock(&adm_ctx.resource->adm_mutex); --> Line 3024 (Lock A)
wait_event(device->misc_wait, ...); --> Line 3030 (Wait X)
drbd_adm_disk_opts()
mutex_lock(&adm_ctx.resource->adm_mutex); --> Line 1582 (Lock A)
get_ldev()
get_ldev_if_state()
_get_ldev_if_state()
put_ldev()
wake_up(&device->misc_wait); --> Line 2108 (Wake X)
#BUG 3
drbd_adm_invalidate_peer()
mutex_lock(&adm_ctx.resource->adm_mutex); --> Line 3101 (Lock A)
wait_event(device->misc_wait, ...); --> Line 3107 (Wait X)
drbd_adm_disk_opts()
mutex_lock(&adm_ctx.resource->adm_mutex); --> Line 1582 (Lock A)
get_ldev()
get_ldev_if_state()
_get_ldev_if_state()
put_ldev()
wake_up(&device->misc_wait); --> Line 2108 (Wake X)
When drbd_adm_attach()/drbd_adm_invalidate()/drbd_adm_invalidate_peer()
is executed, "Wait X" is performed by holding "Lock A". If
drbd_adm_disk_opts() is executed at this time, because "Lock A" has been
already held, "Wake X" cannot be performed to wake up "Wait X", causing
possible deadlocks.
I am not quite sure whether these possible problems are real.
Any feedback would be appreciated, thanks :)
Best wishes,
Jia-Ju Bai
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-02-08 11:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-08 10:55 [BUG] block: drbd: possible deadlocks involving waiting and locking operations Jia-Ju Bai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).