From: Andrew Morton <akpm@linux-foundation.org>
To: Maik Hampel <m.hampel@gmx.de>
Cc: Neil Brown <neilb@suse.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-raid@vger.kernel.org" <linux-raid@vger.kernel.org>
Subject: Re: md: raid10: fix use-after-free of bio
Date: Sat, 28 Jul 2007 23:55:19 -0700 [thread overview]
Message-ID: <20070728235519.1edc6ccb.akpm@linux-foundation.org> (raw)
In-Reply-To: <1185547583.2663.10.camel@c64>
On Fri, 27 Jul 2007 16:46:23 +0200 Maik Hampel <m.hampel@gmx.de> wrote:
> In case of read errors raid10d tries to print a nice error message,
> unfortunately using data from an already put bio.
>
> Signed-off-by: Maik Hampel <m.hampel@gmx.de>
>
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index f730a14..ea1b3e3 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -1557,7 +1557,6 @@ static void raid10d(mddev_t *mddev)
> bio = r10_bio->devs[r10_bio->read_slot].bio;
> r10_bio->devs[r10_bio->read_slot].bio =
> mddev->ro ? IO_BLOCKED : NULL;
> - bio_put(bio);
> mirror = read_balance(conf, r10_bio);
> if (mirror == -1) {
> printk(KERN_ALERT "raid10: %s: unrecoverable I/O"
> @@ -1567,6 +1566,7 @@ static void raid10d(mddev_t *mddev)
> raid_end_bio_io(r10_bio);
> } else {
> const int do_sync = bio_sync(r10_bio->master_bio);
> + bio_put(bio);
> rdev = conf->mirrors[mirror].rdev;
> if (printk_ratelimit())
> printk(KERN_ERR "raid10: %s: redirecting sector %llu to"
>
>
Surely we just leaked that bio if (mirror == -1)?
better:
--- a/drivers/md/raid10.c~md-raid10-fix-use-after-free-of-bio
+++ a/drivers/md/raid10.c
@@ -1534,7 +1534,6 @@ static void raid10d(mddev_t *mddev)
bio = r10_bio->devs[r10_bio->read_slot].bio;
r10_bio->devs[r10_bio->read_slot].bio =
mddev->ro ? IO_BLOCKED : NULL;
- bio_put(bio);
mirror = read_balance(conf, r10_bio);
if (mirror == -1) {
printk(KERN_ALERT "raid10: %s: unrecoverable I/O"
@@ -1542,8 +1541,10 @@ static void raid10d(mddev_t *mddev)
bdevname(bio->bi_bdev,b),
(unsigned long long)r10_bio->sector);
raid_end_bio_io(r10_bio);
+ bio_put(bio);
} else {
const int do_sync = bio_sync(r10_bio->master_bio);
+ bio_put(bio);
rdev = conf->mirrors[mirror].rdev;
if (printk_ratelimit())
printk(KERN_ERR "raid10: %s: redirecting sector %llu to"
_
next prev parent reply other threads:[~2007-07-29 6:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-27 14:46 md: raid10: fix use-after-free of bio Maik Hampel
2007-07-29 6:55 ` Andrew Morton [this message]
2007-07-30 8:11 ` Maik Hampel
2007-07-30 8:44 ` Neil Brown
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=20070728235519.1edc6ccb.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=m.hampel@gmx.de \
--cc=neilb@suse.de \
/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).