From: Christoph Hellwig <hch@infradead.org>
To: Lachlan McIlroy <lachlan@sgi.com>
Cc: xfs-dev <xfs-dev@sgi.com>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH] Fix use after free when closing log/rt devices
Date: Fri, 27 Jun 2008 02:32:19 -0400 [thread overview]
Message-ID: <20080627063219.GA25015@infradead.org> (raw)
In-Reply-To: <48647746.5010007@sgi.com>
On Fri, Jun 27, 2008 at 03:14:46PM +1000, Lachlan McIlroy wrote:
> The call to xfs_free_buftarg() will free the memory used by it's argument
> so we need to save the bdev to pass to xfs_blkdev_put()
>
> Lachlan
>
> --- fs/xfs/linux-2.6/xfs_super.c_1.432 2008-06-27 14:51:17.000000000 +1000
> +++ fs/xfs/linux-2.6/xfs_super.c 2008-06-27 14:59:26.000000000 +1000
> @@ -781,13 +781,17 @@ STATIC void
> xfs_close_devices(
> struct xfs_mount *mp)
> {
> + struct block_device *bdev;
> +
> if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
> + bdev = mp->m_logdev_targp->bt_bdev;
> xfs_free_buftarg(mp->m_logdev_targp);
> - xfs_blkdev_put(mp->m_logdev_targp->bt_bdev);
> + xfs_blkdev_put(bdev);
> }
> if (mp->m_rtdev_targp) {
> + bdev = mp->m_rtdev_targp->bt_bdev;
> xfs_free_buftarg(mp->m_rtdev_targp);
> - xfs_blkdev_put(mp->m_rtdev_targp->bt_bdev);
> + xfs_blkdev_put(bdev);
> }
Looks good, alhough two local variables inside the ifs might be cleaner:
if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) {
struct block_device *logdev = mp->m_logdev_targp->bt_bdev;
xfs_free_buftarg(mp->m_logdev_targp);
xfs_blkdev_put(logdev);
}
...
next prev parent reply other threads:[~2008-06-27 6:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-27 5:14 [PATCH] Fix use after free when closing log/rt devices Lachlan McIlroy
2008-06-27 6:32 ` Christoph Hellwig [this message]
2008-06-27 6:39 ` Mark Goodwin
2008-06-27 9:08 ` Christoph Hellwig
2008-07-02 1:59 ` Timothy Shimmin
2008-07-02 2:54 ` Dave Chinner
2008-07-01 6:21 ` Lachlan McIlroy
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=20080627063219.GA25015@infradead.org \
--to=hch@infradead.org \
--cc=lachlan@sgi.com \
--cc=xfs-dev@sgi.com \
--cc=xfs@oss.sgi.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