From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: philipp.reisner@linbit.com, lars.ellenberg@linbit.com,
Jens Axboe <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: four possible ABBA deadlocks
Date: Thu, 19 Aug 2021 17:31:04 +0800 [thread overview]
Message-ID: <f425ae14-8857-28d7-a27a-d25da83e1bd6@gmail.com> (raw)
Hello,
My static analysis tool reports four possible ABBA deadlocks in the drbd
drivers in Linux 5.10:
### Deadlock A ###
w_after_conn_state_ch()
mutex_lock(&connection->resource->conf_update); --> line 2065
conn_free_crypto()
drbd_free_sock()
drbd_free_one_sock(&connection->data)
mutex_lock(&ds->mutex); --> line 2967
drbd_adm_net_opts()
mutex_lock(&connection->data.mutex); --> line 2445
mutex_lock(&connection->resource->conf_update); --> line 2446
When w_after_conn_state_ch() and drbd_adm_net_opts() are concurrently
executed, the deadlock can occur.
### Deadlock B ###
drbd_adm_connect()
mutex_lock(&adm_ctx.resource->conf_update); --> line 2644
conn_free_crypto()
drbd_free_one_sock(&connection->data)
mutex_lock(&ds->mutex); --> line 2967
drbd_adm_net_opts()
mutex_lock(&connection->data.mutex); --> line 2445
mutex_lock(&connection->resource->conf_update); --> line 2446
When drbd_adm_connect() and drbd_adm_net_opts() are concurrently
executed, the deadlock can occur.
### Deadlock C ###
w_after_conn_state_ch()
mutex_lock(&connection->resource->conf_update); --> line 2065
conn_free_crypto()
drbd_free_sock()
drbd_free_one_sock(&connection->data)
mutex_lock(&ds->mutex); --> line 2967
receive_protocol()
mutex_lock(&connection->data.mutex); --> line 3778
mutex_lock(&connection->resource->conf_update); --> line 3779
When w_after_conn_state_ch() and receive_protocol() are concurrently
executed, the deadlock can occur.
### Deadlock D ###
drbd_adm_connect()
mutex_lock(&adm_ctx.resource->conf_update); --> line 2644
conn_free_crypto()
drbd_free_one_sock(&connection->data)
mutex_lock(&ds->mutex); --> line 2967
receive_protocol()
mutex_lock(&connection->data.mutex); --> line 3778
mutex_lock(&connection->resource->conf_update); --> line 3779
When drbd_adm_connect() and receive_protocol() are concurrently
executed, the deadlock can occur.
I am not quite sure whether these possible deadlocks are real and how to
fix them if they are real.
Any feedback would be appreciated, thanks
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Best wishes,
Jia-Ju Bai
reply other threads:[~2021-08-19 9: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=f425ae14-8857-28d7-a27a-d25da83e1bd6@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;
as well as URLs for NNTP newsgroup(s).