[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0fa90019-5b07-7afb-8915-17c54a22709b@fb.com>
Date: Wed, 28 Jun 2017 12:34:15 -0600
From: Jens Axboe <axboe@...com>
To: Christoph Hellwig <hch@....de>, Keith Busch <keith.busch@...el.com>
CC: <wenxiong@...ux.vnet.ibm.com>, <linux-kernel@...r.kernel.org>,
<bjking@...ux.vnet.ibm.com>
Subject: Re: [PATCH] fs: System memory leak when running HTX with T10 DIF
enabled
On 06/28/2017 12:31 PM, Christoph Hellwig wrote:
> On Wed, Jun 28, 2017 at 01:10:31PM -0400, Keith Busch wrote:
>> On Wed, Jun 28, 2017 at 11:32:51AM -0500, wenxiong@...ux.vnet.ibm.com wrote:
>>> diff --git a/fs/block_dev.c b/fs/block_dev.c
>>> index 519599d..e871444 100644
>>> --- a/fs/block_dev.c
>>> +++ b/fs/block_dev.c
>>> @@ -264,6 +264,10 @@ static void blkdev_bio_end_io_simple(struct bio *bio)
>>>
>>> if (unlikely(bio.bi_error))
>>> return bio.bi_error;
>>> +
>>> + if (bio_integrity(&bio))
>>> + bio_integrity_free(&bio);
>>> +
>>> return ret;
>>> }
>>
>> We don't want to leak the integrity payload in case of bi_error either.
>
> And we should just call __bio_free. Which btw every user of bio_init
> probably needs.
That's what I sent out. Here it is again. We should get this into 4.12,
so would be great with a review or two.
diff --git a/block/bio.c b/block/bio.c
index 888e7801c638..bdc6e6541278 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -240,7 +240,7 @@ struct bio_vec *bvec_alloc(gfp_t gfp_mask, int nr, unsigned long *idx,
return bvl;
}
-static void __bio_free(struct bio *bio)
+void __bio_free(struct bio *bio)
{
bio_disassociate_task(bio);
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 519599dddd36..d929f886ee7b 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -263,7 +263,10 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
kfree(vecs);
if (unlikely(bio.bi_error))
- return bio.bi_error;
+ ret = bio.bi_error;
+
+ __bio_free(&bio);
+
return ret;
}
diff --git a/include/linux/bio.h b/include/linux/bio.h
index d1b04b0e99cf..4a29dc3db8cb 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -380,6 +380,7 @@ extern mempool_t *biovec_create_pool(int pool_entries);
extern struct bio *bio_alloc_bioset(gfp_t, unsigned int, struct bio_set *);
extern void bio_put(struct bio *);
+extern void __bio_free(struct bio *);
extern void __bio_clone_fast(struct bio *, struct bio *);
extern struct bio *bio_clone_fast(struct bio *, gfp_t, struct bio_set *);
--
Jens Axboe
Powered by blists - more mailing lists