From: akpm@linux-foundation.org
To: vitalywool@gmail.com, ddstreet@ieee.org,
Oleksiy.Avramchenko@sony.com, mm-commits@vger.kernel.org
Subject: + z3fold-fix-potential-race-in-z3fold_reclaim_page.patch added to -mm tree
Date: Wed, 13 Sep 2017 14:45:12 -0700 [thread overview]
Message-ID: <59b9a6e8.r5DvOcWHBYba7/mb%akpm@linux-foundation.org> (raw)
The patch titled
Subject: z3fold: fix potential race in z3fold_reclaim_page
has been added to the -mm tree. Its filename is
z3fold-fix-potential-race-in-z3fold_reclaim_page.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/z3fold-fix-potential-race-in-z3fold_reclaim_page.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/z3fold-fix-potential-race-in-z3fold_reclaim_page.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
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
z3fold-fix-potential-race-in-z3fold_reclaim_page.patch
reply other threads:[~2017-09-13 21:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=59b9a6e8.r5DvOcWHBYba7/mb%akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=Oleksiy.Avramchenko@sony.com \
--cc=ddstreet@ieee.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=vitalywool@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.