From: Dan Carpenter <error27@gmail.com>
To: Lars Ellenberg <lars.ellenberg@linbit.com>
Cc: drbd-dev@lists.linbit.com, linux-block@vger.kernel.org
Subject: [bug report] drbd: allow parallel promote/demote actions
Date: Mon, 18 May 2026 16:10:06 +0300 [thread overview]
Message-ID: <agsPrkfvl4VcjUc1@stanley.mountain> (raw)
[ This code is 12 years old. It's weird to me that no one has complained
about this bug in real life but I suppose that unless you have kfree
poisoning or KASAN enabled then probably you wouldn't notice it. ]
Hello Lars Ellenberg,
Commit 9e276872fe16 ("drbd: allow parallel promote/demote actions")
from Apr 28, 2014 (linux-next), leads to the following Smatch static
checker warning:
drivers/block/drbd/drbd_nl.c:4564 drbd_adm_down() error: dereferencing freed memory 'resource' (line 4562)
drivers/block/drbd/drbd_nl.c:4585 drbd_adm_del_resource() error: dereferencing freed memory 'resource' (line 4584)
drivers/block/drbd/drbd_nl.c
4552 /* delete volumes */
4553 idr_for_each_entry(&resource->devices, device, i) {
4554 retcode = adm_del_minor(device);
4555 if (retcode != NO_ERROR) {
4556 /* "can not happen" */
4557 drbd_msg_put_info(adm_ctx->reply_skb, "failed to delete volume");
4558 goto out;
4559 }
4560 }
4561
4562 retcode = adm_del_resource(resource);
^^^^^^^^^^^^^^^^^^^^^^^^^^
This frees "resource"
4563 out:
--> 4564 mutex_unlock(&resource->adm_mutex);
^^^^^^^^^
Use after free.
4565 finish:
4566 adm_ctx->reply_dh->ret_code = retcode;
4567 return 0;
4568 }
This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter
reply other threads:[~2026-05-18 13:10 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=agsPrkfvl4VcjUc1@stanley.mountain \
--to=error27@gmail.com \
--cc=drbd-dev@lists.linbit.com \
--cc=lars.ellenberg@linbit.com \
--cc=linux-block@vger.kernel.org \
/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