android_kernel_samsung_msm8976/mm
Hugh Dickins 925ea8fa69 mm: migrate dirty page without clear_page_dirty_for_io etc
commit 42cb14b110a5698ccf26ce59c4441722605a3743 upstream.

clear_page_dirty_for_io() has accumulated writeback and memcg subtleties
since v2.6.16 first introduced page migration; and the set_page_dirty()
which completed its migration of PageDirty, later had to be moderated to
__set_page_dirty_nobuffers(); then PageSwapBacked had to skip that too.

No actual problems seen with this procedure recently, but if you look into
what the clear_page_dirty_for_io(page)+set_page_dirty(newpage) is actually
achieving, it turns out to be nothing more than moving the PageDirty flag,
and its NR_FILE_DIRTY stat from one zone to another.

It would be good to avoid a pile of irrelevant decrementations and
incrementations, and improper event counting, and unnecessary descent of
the radix_tree under tree_lock (to set the PAGECACHE_TAG_DIRTY which
radix_tree_replace_slot() left in place anyway).

Do the NR_FILE_DIRTY movement, like the other stats movements, while
interrupts still disabled in migrate_page_move_mapping(); and don't even
bother if the zone is the same.  Do the PageDirty movement there under
tree_lock too, where old page is frozen and newpage not yet visible:
bearing in mind that as soon as newpage becomes visible in radix_tree, an
un-page-locked set_page_dirty() might interfere (or perhaps that's just
not possible: anything doing so should already hold an additional
reference to the old page, preventing its migration; but play safe).

But we do still need to transfer PageDirty in migrate_page_copy(), for
those who don't go the mapping route through migrate_page_move_mapping().

CVE-2016-3070

Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[ciwillia@brocade.com: backported to 3.10: adjusted context]
Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>

Change-Id: I3ae67539b3a0ee9157a2e7d4ce8fce1cf8cacf31
2017-05-05 19:20:22 +00:00
..
kasan kasan, module, vmalloc: rework shadow allocation for modules 2015-05-04 14:03:58 -07:00
Kconfig Import latest Samsung release 2017-04-18 03:43:52 +02:00
Kconfig.debug
Makefile BACKPORT: mm/zpool: implement common zpool api to zbud/zsmalloc 2016-05-18 14:35:03 +05:30
backing-dev.c
balloon_compaction.c
bootmem.c
bounce.c
cleancache.c
compaction.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
debug-pagealloc.c mm/debug-pagealloc.c: print page physical address for 2015-08-23 23:19:22 -07:00
dmapool.c
early_ioremap.c
fadvise.c
failslab.c
filemap.c Merge remote-tracking branch 'f2fs/linux-3.10.y' into HEAD 2017-04-18 17:02:28 +02:00
filemap_xip.c
fremap.c
frontswap.c
highmem.c
huge_memory.c
hugetlb.c mm: hugetlbfs: skip shared VMAs when unmapping private pages to satisfy a fault 2015-10-22 14:37:50 -07:00
hugetlb_cgroup.c
hwpoison-inject.c
init-mm.c
internal.h mm: Enhance per process reclaim to consider shared pages 2015-04-16 10:14:27 -07:00
interval_tree.c
kmemcheck.c
kmemleak-test.c
kmemleak.c mm: kmemleak: allow safe memory scanning during kmemleak disabling 2015-06-22 10:47:32 +05:30
ksm.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
maccess.c
madvise.c
memblock.c
memcontrol.c UPSTREAM: memcg: Only free spare array when readers are done 2016-05-18 14:36:06 +05:30
memory-failure.c This is the 3.10.98 stable release 2017-04-18 17:17:24 +02:00
memory.c Merge tag 'LA.BR.1.3.6-03510-8976.0' into HEAD 2017-04-18 12:11:50 +02:00
memory_hotplug.c This is the 3.10.98 stable release 2017-04-18 17:17:24 +02:00
mempolicy.c mm/mempolicy.c: fix error handling in set_mempolicy and mbind. 2017-04-22 23:02:48 +02:00
mempool.c
memtest.c memtest: use phys_addr_t for physical addresses 2015-04-01 09:27:43 -07:00
migrate.c mm: migrate dirty page without clear_page_dirty_for_io etc 2017-05-05 19:20:22 +00:00
mincore.c
mlock.c mm: reorder can_do_mlock to fix audit denial 2015-09-16 18:20:13 +05:30
mm_init.c
mmap.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
mmu_context.c
mmu_notifier.c
mmzone.c
mprotect.c
mremap.c
msync.c
nobootmem.c
nommu.c This is the 3.10.73 stable release 2015-04-24 18:14:57 -07:00
oom_kill.c This is the 3.10.67 stable release 2015-04-24 18:04:40 -07:00
page-writeback.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
page_alloc.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
page_cgroup.c
page_io.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
page_isolation.c mm/page_alloc: Call kernel_map_pages in unset_migrateype_isolate 2015-03-19 11:34:36 -07:00
pageowner.c
pagewalk.c
percpu-km.c
percpu-vm.c
percpu.c
pgtable-generic.c
process_reclaim.c lowmemorykiller: Introduce sysfs node for ALMK and PPR adj threshold 2016-07-06 23:07:02 -07:00
process_vm_access.c ptrace: use fsuid, fsgid, effective creds for fs access checks 2016-02-25 11:57:47 -08:00
quicklist.c
readahead.c
rmap.c mm: Enhance per process reclaim to consider shared pages 2015-04-16 10:14:27 -07:00
shmem.c This is the 3.10.67 stable release 2015-04-24 18:04:40 -07:00
showmem.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
slab.c mm: slub: add kernel address sanitizer support for slub allocator 2015-05-04 14:03:56 -07:00
slab.h
slab_common.c mm: slub: add kernel address sanitizer support for slub allocator 2015-05-04 14:03:56 -07:00
slob.c
slub.c mm: slub: add kernel address sanitizer support for slub allocator 2015-05-04 14:03:56 -07:00
sparse-vmemmap.c
sparse.c
swap.c
swap_state.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
swapfile.c BACKPORT: mm: /proc/pid/smaps:: show proportional swap share of the mapping 2016-05-18 14:35:57 +05:30
truncate.c
util.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
vmalloc.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
vmpressure.c mm: vmpressure: account allocstalls only on higher pressures 2015-08-25 18:34:09 -07:00
vmscan.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
vmstat.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
zbud.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
zpool.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
zsmalloc.c Import latest Samsung release 2017-04-18 03:43:52 +02:00
zswap.c Import latest Samsung release 2017-04-18 03:43:52 +02:00