mm: don't lose the SOFT_DIRTY flag on mprotect
authorAndrey Vagin <[email protected]>
Thu, 30 Jan 2014 23:46:10 +0000 (15:46 -0800)
committerLinus Torvalds <[email protected]>
Fri, 31 Jan 2014 00:56:56 +0000 (16:56 -0800)
commit24f91eba18bbfdb27e71a1aae5b3a61b67fcd091
tree0d2f8a9cf99676eca52508f35de928138c929030
parenta03208652dad18232e9ec3432df69f9c19c856ec
mm: don't lose the SOFT_DIRTY flag on mprotect

The SOFT_DIRTY bit shows that the content of memory was changed after a
defined point in the past.  mprotect() doesn't change the content of
memory, so it must not change the SOFT_DIRTY bit.

This bug causes a malfunction: on the first iteration all pages are
dumped.  On other iterations only pages with the SOFT_DIRTY bit are
dumped.  So if the SOFT_DIRTY bit is cleared from a page by mistake, the
page is not dumped and its content will be restored incorrectly.

This patch does nothing with _PAGE_SWP_SOFT_DIRTY, becase pte_modify()
is called only for present pages.

Fixes commit 0f8975ec4db2 ("mm: soft-dirty bits for user memory changes
tracking").

Signed-off-by: Andrey Vagin <[email protected]>
Acked-by: Cyrill Gorcunov <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Pavel Emelyanov <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Wen Congyang <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
arch/x86/include/asm/pgtable_types.h