2012-06-22 15:00:20

by Mike Snitzer

[permalink] [raw]
Subject: [PATCH] dm thin: reinstate missing mempool_free in cell_release_singleton

Hi Greg,

3.3-stable pulled in upstream commit
6f94a4c45a6f744383f9f695dde019998db3df55 (dm thin: fix stacked bi_next usage)

But later in the 3.4 development window it was determined that that
commit introduced a significant leak. The following upstream commit
fixes it (but unfortunately didn't cc: stable).

-------------------

From: Mike Snitzer <[email protected]>

commit 03aaae7cdc71bc306888440b1f569d463e917b6d upstream.

Fix a significant memory leak inadvertently introduced during
simplification of cell_release_singleton() in commit
6f94a4c45a6f744383f9f695dde019998db3df55 ("dm thin: fix stacked bi_next
usage").

A cell's hlist_del() must be accompanied by a mempool_free().
Use __cell_release() to do this, like before.

Signed-off-by: Mike Snitzer <[email protected]>
Signed-off-by: Alasdair G Kergon <[email protected]>
---
drivers/md/dm-thin.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 213ae32..301db0f 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -279,8 +279,10 @@ static void __cell_release(struct cell *cell, struct bio_list *inmates)

hlist_del(&cell->list);

- bio_list_add(inmates, cell->holder);
- bio_list_merge(inmates, &cell->bios);
+ if (inmates) {
+ bio_list_add(inmates, cell->holder);
+ bio_list_merge(inmates, &cell->bios);
+ }

mempool_free(cell, prison->cell_pool);
}
@@ -303,9 +305,10 @@ static void cell_release(struct cell *cell, struct bio_list *bios)
*/
static void __cell_release_singleton(struct cell *cell, struct bio *bio)
{
- hlist_del(&cell->list);
BUG_ON(cell->holder != bio);
BUG_ON(!bio_list_empty(&cell->bios));
+
+ __cell_release(cell, NULL);
}

static void cell_release_singleton(struct cell *cell, struct bio *bio)
--
1.7.4.4


2012-06-22 15:16:57

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] dm thin: reinstate missing mempool_free in cell_release_singleton

On Fri, Jun 22, 2012 at 10:59:48AM -0400, Mike Snitzer wrote:
> Hi Greg,
>
> 3.3-stable pulled in upstream commit
> 6f94a4c45a6f744383f9f695dde019998db3df55 (dm thin: fix stacked bi_next usage)
>
> But later in the 3.4 development window it was determined that that
> commit introduced a significant leak. The following upstream commit
> fixes it (but unfortunately didn't cc: stable).

3.3 is end-of-life, so there's not much I can do with the 3.3-stable
tree anymore, sorry. If there's any other tree I should apply this to
that is active (i.e. 3.0 or 3.4), please let me know.

sorry,

greg k-h

2012-06-22 15:27:41

by Mike Snitzer

[permalink] [raw]
Subject: Re: dm thin: reinstate missing mempool_free in cell_release_singleton

On Fri, Jun 22 2012 at 11:16am -0400,
Greg KH <[email protected]> wrote:

> On Fri, Jun 22, 2012 at 10:59:48AM -0400, Mike Snitzer wrote:
> > Hi Greg,
> >
> > 3.3-stable pulled in upstream commit
> > 6f94a4c45a6f744383f9f695dde019998db3df55 (dm thin: fix stacked bi_next usage)
> >
> > But later in the 3.4 development window it was determined that that
> > commit introduced a significant leak. The following upstream commit
> > fixes it (but unfortunately didn't cc: stable).
>
> 3.3 is end-of-life, so there's not much I can do with the 3.3-stable
> tree anymore, sorry. If there's any other tree I should apply this to
> that is active (i.e. 3.0 or 3.4), please let me know.

OK, no other active stable tree is affected, thanks.

2012-06-22 16:31:08

by Touko Korpela

[permalink] [raw]
Subject: Re: [PATCH] dm thin: reinstate missing mempool_free in cell_release_singleton

Greg KH wrote:
> On Fri, Jun 22, 2012 at 10:59:48AM -0400, Mike Snitzer wrote:
> > Hi Greg,
> >
> > 3.3-stable pulled in upstream commit
> > 6f94a4c45a6f744383f9f695dde019998db3df55 (dm thin: fix stacked bi_next
> > usage)
> >
> > But later in the 3.4 development window it was determined that that
> > commit introduced a significant leak. The following upstream commit
> > fixes it (but unfortunately didn't cc: stable).
>
> 3.3 is end-of-life, so there's not much I can do with the 3.3-stable
> tree anymore, sorry. If there's any other tree I should apply this to
> that is active (i.e. 3.0 or 3.4), please let me know.

Looks like you forgot 3.2 that is affected (since 3.2.14).

2012-06-22 16:48:50

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] dm thin: reinstate missing mempool_free in cell_release_singleton

On Fri, Jun 22, 2012 at 07:21:27PM +0300, Touko Korpela wrote:
> Greg KH wrote:
> > On Fri, Jun 22, 2012 at 10:59:48AM -0400, Mike Snitzer wrote:
> > > Hi Greg,
> > >
> > > 3.3-stable pulled in upstream commit
> > > 6f94a4c45a6f744383f9f695dde019998db3df55 (dm thin: fix stacked bi_next
> > > usage)
> > >
> > > But later in the 3.4 development window it was determined that that
> > > commit introduced a significant leak. The following upstream commit
> > > fixes it (but unfortunately didn't cc: stable).
> >
> > 3.3 is end-of-life, so there's not much I can do with the 3.3-stable
> > tree anymore, sorry. If there's any other tree I should apply this to
> > that is active (i.e. 3.0 or 3.4), please let me know.
>
> Looks like you forgot 3.2 that is affected (since 3.2.14).

I don't maintain 3.2 :)

2012-06-27 01:52:10

by Ben Hutchings

[permalink] [raw]
Subject: Re: [PATCH] dm thin: reinstate missing mempool_free in cell_release_singleton

On Fri, 2012-06-22 at 19:21 +0300, Touko Korpela wrote:
> Greg KH wrote:
> > On Fri, Jun 22, 2012 at 10:59:48AM -0400, Mike Snitzer wrote:
> > > Hi Greg,
> > >
> > > 3.3-stable pulled in upstream commit
> > > 6f94a4c45a6f744383f9f695dde019998db3df55 (dm thin: fix stacked bi_next
> > > usage)
> > >
> > > But later in the 3.4 development window it was determined that that
> > > commit introduced a significant leak. The following upstream commit
> > > fixes it (but unfortunately didn't cc: stable).
> >
> > 3.3 is end-of-life, so there's not much I can do with the 3.3-stable
> > tree anymore, sorry. If there's any other tree I should apply this to
> > that is active (i.e. 3.0 or 3.4), please let me know.
>
> Looks like you forgot 3.2 that is affected (since 3.2.14).

I've added this to the queue for 3.2, thanks.

Ben.

--
Ben Hutchings
Lowery's Law:
If it jams, force it. If it breaks, it needed replacing anyway.


Attachments:
signature.asc (828.00 B)
This is a digitally signed message part