From: Shaohua Li <shli@kernel.org>
To: linux-mm@kvack.org
Cc: asavkov@redhat.com, Kernel-team@fb.com, Shaohua Li <shli@fb.com>
Subject: [PATCH V3 0/2] mm: fix race condition in MADV_FREE
Date: Tue, 26 Sep 2017 10:26:24 -0700 [thread overview]
Message-ID: <cover.1506446061.git.shli@fb.com> (raw)
From: Shaohua Li <shli@fb.com>
Artem Savkov reported a race condition[1] in MADV_FREE. MADV_FREE clear pte
dirty bit and then mark the page lazyfree. There is no lock to prevent the
page is added to swap cache between these two steps by page reclaim. There are
two problems:
- page in swapcache is marked lazyfree (clear SwapBacked). This confuses some
code pathes, like page fault handling.
- The page is added into swapcache, and freed but the page isn't swapout
because pte isn't dirty. This will cause data corruption.
The patches will fix the issues.
I knew Minchan suggested these should be combined to one patch, but I really
think the separation makes things clearer because these are two issues even
they are stemmed from the same race.
Thanks,
Shaohua
V2->V3:
- reword patch log and code comments, no code change
V1->V2:
- dirty page in add_to_swap instead of in shrink_page_list as suggested by Minchan
Shaohua Li (2):
mm: avoid marking swap cached page as lazyfree
mm: fix data corruption caused by lazyfree page
mm/swap.c | 4 ++--
mm/swap_state.c | 11 +++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
--
2.9.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2017-09-26 17:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-26 17:26 Shaohua Li [this message]
2017-09-26 17:26 ` [PATCH V3 1/2] mm: avoid marking swap cached page as lazyfree Shaohua Li
2017-09-26 19:25 ` Johannes Weiner
2017-09-26 20:23 ` Michal Hocko
2017-09-26 23:20 ` Minchan Kim
2017-09-26 17:26 ` [PATCH V3 2/2] mm: fix data corruption caused by lazyfree page Shaohua Li
2017-09-26 19:40 ` Johannes Weiner
2017-09-26 19:46 ` Shaohua Li
2017-09-26 23:20 ` Minchan Kim
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=cover.1506446061.git.shli@fb.com \
--to=shli@kernel.org \
--cc=Kernel-team@fb.com \
--cc=asavkov@redhat.com \
--cc=linux-mm@kvack.org \
--cc=shli@fb.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 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).