From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: philipp.reisner@linbit.com, lars.ellenberg@linbit.com, axboe@kernel.dk
Cc: drbd-dev@lists.linbit.com, linux-block@vger.kernel.org,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: [BUG] block: drbd: possible deadlocks involving waiting and locking operations
Date: Tue, 8 Feb 2022 18:55:20 +0800 [thread overview]
Message-ID: <3b992e3b-bf1a-426a-5e76-a822f5bf6e6a@gmail.com> (raw)
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
reply other threads:[~2022-02-08 11:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3b992e3b-bf1a-426a-5e76-a822f5bf6e6a@gmail.com \
--to=baijiaju1990@gmail.com \
--cc=axboe@kernel.dk \
--cc=drbd-dev@lists.linbit.com \
--cc=lars.ellenberg@linbit.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=philipp.reisner@linbit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®