mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [merged] z3fold-fix-potential-race-in-z3fold_reclaim_page.patch removed from -mm tree
@ 2017-10-04 19:40 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2017-10-04 19:40 UTC (permalink / raw)
  To: ddstreet, mm-commits, Oleksiy.Avramchenko, vitalywool


The patch titled
     Subject: z3fold: fix potential race in z3fold_reclaim_page
has been removed from the -mm tree.  Its filename was
     z3fold-fix-potential-race-in-z3fold_reclaim_page.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Vitaly Wool <vitalywool@gmail.com>
Subject: z3fold: fix potential race in z3fold_reclaim_page

It is possible that on a (partially) unsuccessful page reclaim, kref_put()
called in z3fold_reclaim_page() does not yield page release, but the page
is released shortly afterwards by another thread.  Then
z3fold_reclaim_page() would try to list_add() that (released) page again
which is obviously a bug.

To avoid that, spin_lock() has to be taken earlier, before the kref_put()
call mentioned earlier.

Link: http://lkml.kernel.org/r/20170913162937.bfff21c7d12b12a5f47639fd@gmail.com
Signed-off-by: Vitaly Wool <vitalywool@gmail.com>
Cc: Dan Streetman <ddstreet@ieee.org>
Cc: <Oleksiy.Avramchenko@sony.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/z3fold.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff -puN mm/z3fold.c~z3fold-fix-potential-race-in-z3fold_reclaim_page mm/z3fold.c
--- a/mm/z3fold.c~z3fold-fix-potential-race-in-z3fold_reclaim_page
+++ a/mm/z3fold.c
@@ -875,16 +875,18 @@ static int z3fold_reclaim_page(struct z3
 				goto next;
 		}
 next:
+		spin_lock(&pool->lock);
 		if (test_bit(PAGE_HEADLESS, &page->private)) {
 			if (ret == 0) {
+				spin_unlock(&pool->lock);
 				free_z3fold_page(page);
 				return 0;
 			}
 		} else if (kref_put(&zhdr->refcount, release_z3fold_page)) {
 			atomic64_dec(&pool->pages_nr);
+			spin_unlock(&pool->lock);
 			return 0;
 		}
-		spin_lock(&pool->lock);
 
 		/*
 		 * Add to the beginning of LRU.
_

Patches currently in -mm which might be from vitalywool@gmail.com are



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-10-04 19:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-04 19:40 [merged] z3fold-fix-potential-race-in-z3fold_reclaim_page.patch removed from -mm tree akpm

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).