linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mm: fix race condition in MADV_FREE
@ 2017-09-21 20:27 Shaohua Li
  2017-09-21 20:27 ` [PATCH 1/2] mm: avoid marking swap cached page as lazyfree Shaohua Li
  2017-09-21 20:27 ` [PATCH 2/2] mm: fix data corruption caused by lazyfree page Shaohua Li
  0 siblings, 2 replies; 6+ messages in thread
From: Shaohua Li @ 2017-09-21 20:27 UTC (permalink / raw)
  To: linux-mm; +Cc: Artem Savkov, Kernel-team, Shaohua Li

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 dity. This will cause data corruption.

The patches will fix the issues.

Thanks,
Shaohua

[1] https://marc.info/?l=linux-mm&m=150589811300667&w=2

Shaohua Li (2):
  mm: avoid marking swap cached page as lazyfree
  mm: fix data corruption caused by lazyfree page

 mm/swap.c   |  4 ++--
 mm/vmscan.c | 12 ++++++++++++
 2 files changed, 14 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>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-09-22 18:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-21 20:27 [PATCH 0/2] mm: fix race condition in MADV_FREE Shaohua Li
2017-09-21 20:27 ` [PATCH 1/2] mm: avoid marking swap cached page as lazyfree Shaohua Li
2017-09-22  1:34   ` Rik van Riel
2017-09-21 20:27 ` [PATCH 2/2] mm: fix data corruption caused by lazyfree page Shaohua Li
2017-09-22  6:01   ` Minchan Kim
2017-09-22 18:45     ` Shaohua Li

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