public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: Fix leak of discard bio
@ 2017-08-02  8:37 Jan Kara
  2017-08-02 11:33 ` Dave Chinner
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jan Kara @ 2017-08-02  8:37 UTC (permalink / raw)
  To: linux-xfs; +Cc: Christoph Hellwig, Darrick J . Wong, Jan Kara, stable

The bio describing discard operation is allocated by
__blkdev_issue_discard() which returns us a reference to it. That
reference is never released and thus we leak this bio. Drop the bio
reference once it completes in xlog_discard_endio().

CC: stable@vger.kernel.org
Fixes: 4560e78f40cb55bd2ea8f1ef4001c5baa88531c7
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/xfs/xfs_log_cil.c | 1 +
 1 file changed, 1 insertion(+)

Note, this is untested. It's just something I've noticed when looking at the
code.

diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index fbe72b134bef..43aa42a3a5d3 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -539,6 +539,7 @@ xlog_discard_endio(
 
 	INIT_WORK(&ctx->discard_endio_work, xlog_discard_endio_work);
 	queue_work(xfs_discard_wq, &ctx->discard_endio_work);
+	bio_put(bio);
 }
 
 static void
-- 
2.12.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] xfs: Fix leak of discard bio
  2017-08-02  8:37 [PATCH] xfs: Fix leak of discard bio Jan Kara
@ 2017-08-02 11:33 ` Dave Chinner
  2017-08-02 13:17   ` Jan Kara
  2017-08-02 19:37 ` Darrick J. Wong
  2017-08-05 13:56 ` Christoph Hellwig
  2 siblings, 1 reply; 5+ messages in thread
From: Dave Chinner @ 2017-08-02 11:33 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-xfs, Christoph Hellwig, Darrick J . Wong, stable

On Wed, Aug 02, 2017 at 10:37:41AM +0200, Jan Kara wrote:
> The bio describing discard operation is allocated by
> __blkdev_issue_discard() which returns us a reference to it. That
> reference is never released and thus we leak this bio. Drop the bio
> reference once it completes in xlog_discard_endio().
> 
> CC: stable@vger.kernel.org
> Fixes: 4560e78f40cb55bd2ea8f1ef4001c5baa88531c7
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
>  fs/xfs/xfs_log_cil.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> Note, this is untested. It's just something I've noticed when looking at the
> code.
> 
> diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> index fbe72b134bef..43aa42a3a5d3 100644
> --- a/fs/xfs/xfs_log_cil.c
> +++ b/fs/xfs/xfs_log_cil.c
> @@ -539,6 +539,7 @@ xlog_discard_endio(
>  
>  	INIT_WORK(&ctx->discard_endio_work, xlog_discard_endio_work);
>  	queue_work(xfs_discard_wq, &ctx->discard_endio_work);
> +	bio_put(bio);
>  }

At a quick glance, it does seem that we are leaking the bio here. It
appears to me that ext4_process_freed_data() also has the same
problem and leaks the discard_bio....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xfs: Fix leak of discard bio
  2017-08-02 11:33 ` Dave Chinner
@ 2017-08-02 13:17   ` Jan Kara
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Kara @ 2017-08-02 13:17 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Jan Kara, linux-xfs, Christoph Hellwig, Darrick J . Wong, stable

On Wed 02-08-17 21:33:49, Dave Chinner wrote:
> On Wed, Aug 02, 2017 at 10:37:41AM +0200, Jan Kara wrote:
> > The bio describing discard operation is allocated by
> > __blkdev_issue_discard() which returns us a reference to it. That
> > reference is never released and thus we leak this bio. Drop the bio
> > reference once it completes in xlog_discard_endio().
> > 
> > CC: stable@vger.kernel.org
> > Fixes: 4560e78f40cb55bd2ea8f1ef4001c5baa88531c7
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > ---
> >  fs/xfs/xfs_log_cil.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > Note, this is untested. It's just something I've noticed when looking at the
> > code.
> > 
> > diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> > index fbe72b134bef..43aa42a3a5d3 100644
> > --- a/fs/xfs/xfs_log_cil.c
> > +++ b/fs/xfs/xfs_log_cil.c
> > @@ -539,6 +539,7 @@ xlog_discard_endio(
> >  
> >  	INIT_WORK(&ctx->discard_endio_work, xlog_discard_endio_work);
> >  	queue_work(xfs_discard_wq, &ctx->discard_endio_work);
> > +	bio_put(bio);
> >  }
> 
> At a quick glance, it does seem that we are leaking the bio here. It
> appears to me that ext4_process_freed_data() also has the same
> problem and leaks the discard_bio....

Yes, and a fix of that prompted me to look into how XFS does things ;)

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xfs: Fix leak of discard bio
  2017-08-02  8:37 [PATCH] xfs: Fix leak of discard bio Jan Kara
  2017-08-02 11:33 ` Dave Chinner
@ 2017-08-02 19:37 ` Darrick J. Wong
  2017-08-05 13:56 ` Christoph Hellwig
  2 siblings, 0 replies; 5+ messages in thread
From: Darrick J. Wong @ 2017-08-02 19:37 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-xfs, Christoph Hellwig, stable

On Wed, Aug 02, 2017 at 10:37:41AM +0200, Jan Kara wrote:
> The bio describing discard operation is allocated by
> __blkdev_issue_discard() which returns us a reference to it. That
> reference is never released and thus we leak this bio. Drop the bio
> reference once it completes in xlog_discard_endio().
> 
> CC: stable@vger.kernel.org
> Fixes: 4560e78f40cb55bd2ea8f1ef4001c5baa88531c7
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
>  fs/xfs/xfs_log_cil.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> Note, this is untested. It's just something I've noticed when looking at the
> code.
> 
> diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> index fbe72b134bef..43aa42a3a5d3 100644
> --- a/fs/xfs/xfs_log_cil.c
> +++ b/fs/xfs/xfs_log_cil.c
> @@ -539,6 +539,7 @@ xlog_discard_endio(
>  
>  	INIT_WORK(&ctx->discard_endio_work, xlog_discard_endio_work);
>  	queue_work(xfs_discard_wq, &ctx->discard_endio_work);
> +	bio_put(bio);

It would seem that we /do/ leak the bio here. :(

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

>  }
>  
>  static void
> -- 
> 2.12.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xfs: Fix leak of discard bio
  2017-08-02  8:37 [PATCH] xfs: Fix leak of discard bio Jan Kara
  2017-08-02 11:33 ` Dave Chinner
  2017-08-02 19:37 ` Darrick J. Wong
@ 2017-08-05 13:56 ` Christoph Hellwig
  2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2017-08-05 13:56 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-xfs, Christoph Hellwig, Darrick J . Wong, stable

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-05 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-02  8:37 [PATCH] xfs: Fix leak of discard bio Jan Kara
2017-08-02 11:33 ` Dave Chinner
2017-08-02 13:17   ` Jan Kara
2017-08-02 19:37 ` Darrick J. Wong
2017-08-05 13:56 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox