From: Alex Elder <elder@inktank.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Sage Weil <sage@inktank.com>, ceph-devel@vger.kernel.org
Subject: Re: Use-after-free error in rbd_add()
Date: Thu, 09 May 2013 21:09:35 -0500 [thread overview]
Message-ID: <518C56DF.70206@inktank.com> (raw)
In-Reply-To: <CAErSpo79gvppE0xb6c1OB65ia6vSO-f8KunH4wrF_EGP2DdD4Q@mail.gmail.com>
On 05/09/2013 05:42 PM, Bjorn Helgaas wrote:
> I think b536f69a3a5 "rbd: set up devices only for mapped images"
> introduced a use-after-free error in rbd_add():
>
> @@ -4964,9 +4960,12 @@ static ssize_t rbd_add(struct bus_type *bus,
> if (rc < 0)
> goto err_out_rbd_dev;
>
> - return count;
> + rc = rbd_dev_device_setup(rbd_dev);
> + if (!rc)
> + return count;
> +
> + rbd_dev_image_release(rbd_dev);
> err_out_rbd_dev:
> - kfree(rbd_dev->header_name);
> rbd_dev_destroy(rbd_dev);
>
> If rbd_dev_device_setup() returns an error, we call
> rbd_dev_image_release(), which ultimately kfrees rbd_dev. Then we
> call rbd_dev_destroy(), which references fields in the already-freed
> rbd_dev struct before kfreeing it again.
Thank you. I think you're right, I'll try to
have a fix prepared tomorrow.
-Alex
> Found by Coverity (CID 1020653).
>
> Bjorn
>
prev parent reply other threads:[~2013-05-10 2:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-09 22:42 Use-after-free error in rbd_add() Bjorn Helgaas
2013-05-10 2:09 ` Alex Elder [this message]
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=518C56DF.70206@inktank.com \
--to=elder@inktank.com \
--cc=bhelgaas@google.com \
--cc=ceph-devel@vger.kernel.org \
--cc=sage@inktank.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