From: Bart Van Assche <bvanassche@acm.org>
To: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: device-mapper development <dm-devel@redhat.com>,
linux-scsi <linux-scsi@vger.kernel.org>,
Alasdair G Kergon <agk@redhat.com>, Jens Axboe <axboe@kernel.dk>,
Mike Snitzer <snitzer@redhat.com>, Tejun Heo <tj@kernel.org>,
James Bottomley <JBottomley@parallels.com>
Subject: Re: [PATCH 2/2] dm: Avoid use-after-free of a mapped device
Date: Mon, 25 Feb 2013 16:09:52 +0100 [thread overview]
Message-ID: <512B7EC0.8090400@acm.org> (raw)
In-Reply-To: <512B339A.7010606@ce.jp.nec.com>
On 02/25/13 10:49, Jun'ichi Nomura wrote:
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index 314a0e2..51fefb5 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -1973,15 +1973,27 @@ static void __bind_mempools(struct mapped_device *md, struct dm_table *t)
> {
> struct dm_md_mempools *p = dm_table_get_md_mempools(t);
>
> - if (md->io_pool && (md->tio_pool || dm_table_get_type(t) == DM_TYPE_BIO_BASED) && md->bs) {
> - /*
> - * The md already has necessary mempools. Reload just the
> - * bioset because front_pad may have changed because
> - * a different table was loaded.
> - */
> - bioset_free(md->bs);
> - md->bs = p->bs;
> - p->bs = NULL;
> + if (md->io_pool && md->bs) {
> + /* The md already has necessary mempools. */
> + if (dm_table_get_type(t) == DM_TYPE_BIO_BASED) {
> + /*
> + * Reload bioset because front_pad may have changed
> + * because a different table was loaded.
> + */
> + bioset_free(md->bs);
> + md->bs = p->bs;
> + p->bs = NULL;
> + } else if (dm_table_get_type(t) == DM_TYPE_REQUEST_BASED) {
> + BUG_ON(!md->tio_pool);
> + /*
> + * No need to reload in case of request-based dm
> + * because of fixed size front_pad.
> + * Note for future: if you are to reload bioset,
> + * prep-ed requests in queue may have reference
> + * to bio from the old bioset.
> + * So you must walk through the queue to unprep.
> + */
> + }
> goto out;
> }
Without your patch my test failed after two or three iterations. With
your patch my test is still running after 53 iterations. So if you want
you can add Tested-by: Bart Van Assche <bvanassche@acm.org>.
Your e-mail and the above patch are also interesting because these
explain why reverting to the v3.7 of drivers/md made my test succeed.
Note: even if this patch gets accepted I think it's still useful to
modify blk_run_queue() such that it converts recursion into iteration.
Bart.
next prev parent reply other threads:[~2013-02-25 15:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-22 10:45 [PATCH 0/2] dm: Avoid use-after-free of a mapped device Bart Van Assche
2013-02-22 10:46 ` [PATCH 1/2] block: Avoid invoking blk_run_queue() recursively Bart Van Assche
2013-02-22 18:14 ` Tejun Heo
2013-02-22 18:57 ` Bart Van Assche
2013-02-22 19:01 ` Jens Axboe
2013-02-23 12:34 ` Bart Van Assche
2013-02-22 10:47 ` [PATCH 2/2] dm: Avoid use-after-free of a mapped device Bart Van Assche
2013-02-22 11:08 ` Mike Snitzer
2013-02-22 11:22 ` Bart Van Assche
2013-02-22 11:28 ` Mike Snitzer
2013-02-25 9:49 ` Jun'ichi Nomura
2013-02-25 15:09 ` Bart Van Assche [this message]
2013-02-26 0:30 ` Jun'ichi Nomura
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=512B7EC0.8090400@acm.org \
--to=bvanassche@acm.org \
--cc=JBottomley@parallels.com \
--cc=agk@redhat.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=j-nomura@ce.jp.nec.com \
--cc=linux-scsi@vger.kernel.org \
--cc=snitzer@redhat.com \
--cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.