linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neil Brown <neilb@suse.de>
To: Maik Hampel <m.hampel@gmx.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"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: Mon, 30 Jul 2007 18:44:37 +1000	[thread overview]
Message-ID: <18093.42229.134557.618117@notabene.brown> (raw)
In-Reply-To: message from Maik Hampel on Monday July 30

On Monday July 30, m.hampel@gmx.de wrote:
> > 
> > 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);
> raid_end_bio_io() calls put_all_bios(), which does a bio_put() to
> corresponding r10_bio->devs[i]. So this looks like redundant code for
> me.

Yes, but note above that this bio for this slot has been set to
'NULL', so put_all_bios won't find anything to call bio_put on.

Thanks,
NeilBrown


> >  			} 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"
> 
> Regards, 
> Maik Hampel
> 

      reply	other threads:[~2007-07-30  8:44 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
2007-07-30  8:11   ` Maik Hampel
2007-07-30  8:44     ` Neil Brown [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=18093.42229.134557.618117@notabene.brown \
    --to=neilb@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=m.hampel@gmx.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).