WSL2-Linux-Kernel/mm
Hugh Dickins 4e31635c36 ksm: fix bad user data when swapping
Building under memory pressure, with KSM on 2.6.36-rc5, collapsed with
an internal compiler error: typically indicating an error in swapping.

Perhaps there's a timing issue which makes it now more likely, perhaps
it's just a long time since I tried for so long: this bug goes back to
KSM swapping in 2.6.33.

Notice how reuse_swap_page() allows an exclusive page to be reused, but
only does SetPageDirty if it can delete it from swap cache right then -
if it's currently under Writeback, it has to be left in cache and we
don't SetPageDirty, but the page can be reused.  Fine, the dirty bit
will get set in the pte; but notice how zap_pte_range() does not bother
to transfer pte_dirty to page_dirty when unmapping a PageAnon.

If KSM chooses to share such a page, it will look like a clean copy of
swapcache, and not be written out to swap when its memory is needed;
then stale data read back from swap when it's needed again.

We could fix this in reuse_swap_page() (or even refuse to reuse a
page under writeback), but it's more honest to fix my oversight in
KSM's write_protect_page().  Several days of testing on three machines
confirms that this fixes the issue they showed.

Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-10-04 11:09:53 -07:00
..
Kconfig mm: avoid warning when COMPACTION is selected 2010-09-09 18:57:24 -07:00
Kconfig.debug
Makefile
backing-dev.c bdi: Initialize noop_backing_dev_info properly 2010-09-22 09:48:47 +02:00
bootmem.c
bounce.c bounce: call flush_dcache_page() after bounce_copy_vec() 2010-09-09 18:57:25 -07:00
compaction.c mm: compaction: handle active and inactive fairly in too_many_isolated 2010-09-09 18:57:24 -07:00
debug-pagealloc.c
dmapool.c
fadvise.c
failslab.c
filemap.c
filemap_xip.c
fremap.c Avoid pgoff overflow in remap_file_pages 2010-09-25 09:34:58 -07:00
highmem.c
hugetlb.c hugetlb, rmap: fix confusing page locking in hugetlb_cow() 2010-09-23 17:29:18 -07:00
hwpoison-inject.c
init-mm.c
internal.h
kmemcheck.c
kmemleak-test.c
kmemleak.c
ksm.c ksm: fix bad user data when swapping 2010-10-04 11:09:53 -07:00
maccess.c
madvise.c
memblock.c
memcontrol.c
memory-failure.c
memory.c mm: further fix swapin race condition 2010-09-20 10:44:37 -07:00
memory_hotplug.c memory hotplug: fix next block calculation in is_removable 2010-09-09 18:57:24 -07:00
mempolicy.c
mempool.c
migrate.c
mincore.c
mlock.c mm: Move vma_stack_continue into mm.h 2010-09-09 09:05:06 -07:00
mm_init.c
mmap.c mmap: call unlink_anon_vmas() in __split_vma() in case of error 2010-09-22 17:22:40 -07:00
mmu_context.c
mmu_notifier.c
mmzone.c mm: page allocator: calculate a better estimate of NR_FREE_PAGES when memory is low and kswapd is awake 2010-09-09 18:57:25 -07:00
mprotect.c
mremap.c
msync.c
nommu.c mm: make the vma list be doubly linked 2010-08-21 08:49:21 -07:00
oom_kill.c oom: filter unkillable tasks from tasklist dump 2010-09-22 17:22:39 -07:00
page-writeback.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client 2010-08-28 14:07:20 -07:00
page_alloc.c mm: page allocator: drain per-cpu lists after direct reclaim allocation fails 2010-09-09 18:57:25 -07:00
page_cgroup.c
page_io.c
page_isolation.c
pagewalk.c
percpu-km.c
percpu-vm.c
percpu.c percpu: fix pcpu_last_unit_cpu 2010-09-21 08:12:25 +02:00
percpu_up.c
prio_tree.c
quicklist.c
readahead.c
rmap.c ksm: fix page_address_in_vma anon_vma oops 2010-10-04 11:09:53 -07:00
shmem.c shmem: put_super must percpu_counter_destroy 2010-08-17 18:33:11 -07:00
slab.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/penberg/slab-2.6 2010-08-22 10:08:52 -07:00
slob.c
slub.c
sparse-vmemmap.c
sparse.c
swap.c
swap_state.c
swapfile.c swap: discard while swapping only if SWAP_FLAG_DISCARD 2010-09-09 18:57:25 -07:00
thrash.c
truncate.c
util.c
vmalloc.c
vmscan.c vmscan: check all_unreclaimable in direct reclaim path 2010-09-22 17:22:39 -07:00
vmstat.c mm: page allocator: calculate a better estimate of NR_FREE_PAGES when memory is low and kswapd is awake 2010-09-09 18:57:25 -07:00