linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Chandan Rajendra <chandan@linux.ibm.com>,
	"Darrick J . Wong" <darrick.wong@oracle.com>
Subject: Re: [PATCH] iomap: fix a use after free in iomap_dio_rw
Date: Fri, 18 Jan 2019 08:26:58 +1100	[thread overview]
Message-ID: <20190117212658.GD6173@dastard> (raw)
In-Reply-To: <20190117075707.8640-1-hch@lst.de>

On Thu, Jan 17, 2019 at 08:57:07AM +0100, Christoph Hellwig wrote:
> Introduce a local wait_for_completion variable to avoid an access to the
> potentially freed dio struture after dropping the last reference count.
> 
> Also use the chance to document the completion behavior to make the
> refcounting clear to the reader of the code.
> 
> Fixes: ff6a9292e6 ("iomap: implement direct I/O")
> Reported-by: Chandan Rajendra <chandan@linux.ibm.com>
> Reported-by: Darrick J. Wong <darrick.wong@oracle.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Tested-by: Chandan Rajendra <chandan@linux.ibm.com>
> Tested-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/iomap.c | 28 +++++++++++++++++++++-------
>  1 file changed, 21 insertions(+), 7 deletions(-)

Looks good, minor comment cleanup needed, though. maybe Darrick can
do it on commit?

Reviewed-by: Dave Chinner <dchinner@redhat.com>

> @@ -1925,8 +1925,24 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
>  	if (dio->flags & IOMAP_DIO_WRITE_FUA)
>  		dio->flags &= ~IOMAP_DIO_NEED_SYNC;
>  
> +	/*
> +	 * We are about to drop our additional submission reference, which
> +	 * might be the last reference to the dio.  There are three three
> +	 * different ways we can progress here:
> +	 *
> +	 *  (a) If this is the last reference we will always complete and free
> +	 *	the dio ourselves. right here.

s/ right here.//

-Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2019-01-17 21:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17  7:57 [PATCH] iomap: fix a use after free in iomap_dio_rw Christoph Hellwig
2019-01-17 21:26 ` Dave Chinner [this message]
2019-01-28 16:22   ` Darrick J. Wong
2019-01-28 16:28     ` Christoph Hellwig
2019-01-28 16:42       ` Darrick J. Wong

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=20190117212658.GD6173@dastard \
    --to=david@fromorbit.com \
    --cc=chandan@linux.ibm.com \
    --cc=darrick.wong@oracle.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.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 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).