Revision 4837fe37adff1d159904f0c013471b1ecbcb455e authored by Michal Hocko on 14 December 2017, 23:33:15 UTC, committed by Linus Torvalds on 15 December 2017, 00:00:49 UTC
David Rientjes has reported the following memory corruption while the oom reaper tries to unmap the victims address space BUG: Bad page map in process oom_reaper pte:6353826300000000 pmd:00000000 addr:00007f50cab1d000 vm_flags:08100073 anon_vma:ffff9eea335603f0 mapping: (null) index:7f50cab1d file: (null) fault: (null) mmap: (null) readpage: (null) CPU: 2 PID: 1001 Comm: oom_reaper Call Trace: unmap_page_range+0x1068/0x1130 __oom_reap_task_mm+0xd5/0x16b oom_reaper+0xff/0x14c kthread+0xc1/0xe0 Tetsuo Handa has noticed that the synchronization inside exit_mmap is insufficient. We only synchronize with the oom reaper if tsk_is_oom_victim which is not true if the final __mmput is called from a different context than the oom victim exit path. This can trivially happen from context of any task which has grabbed mm reference (e.g. to read /proc/<pid>/ file which requires mm etc.). The race would look like this oom_reaper oom_victim task mmget_not_zero do_exit mmput __oom_reap_task_mm mmput __mmput exit_mmap remove_vma unmap_page_range Fix this issue by providing a new mm_is_oom_victim() helper which operates on the mm struct rather than a task. Any context which operates on a remote mm struct should use this helper in place of tsk_is_oom_victim. The flag is set in mark_oom_victim and never cleared so it is stable in the exit_mmap path. Debugged by Tetsuo Handa. Link: http://lkml.kernel.org/r/20171210095130.17110-1-mhocko@kernel.org Fixes: 212925802454 ("mm: oom: let oom_reap_task and exit_mmap run concurrently") Signed-off-by: Michal Hocko <mhocko@suse.com> Reported-by: David Rientjes <rientjes@google.com> Acked-by: David Rientjes <rientjes@google.com> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Andrea Argangeli <andrea@kernel.org> Cc: <stable@vger.kernel.org> [4.14] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent bdcf0a4
File | Mode | Size |
---|---|---|
Makefile | -rw-r--r-- | 1.5 KB |
amdtopology.c | -rw-r--r-- | 4.0 KB |
debug_pagetables.c | -rw-r--r-- | 997 bytes |
dump_pagetables.c | -rw-r--r-- | 13.7 KB |
extable.c | -rw-r--r-- | 7.5 KB |
fault.c | -rw-r--r-- | 37.9 KB |
highmem_32.c | -rw-r--r-- | 3.2 KB |
hugetlbpage.c | -rw-r--r-- | 5.2 KB |
ident_map.c | -rw-r--r-- | 3.1 KB |
init.c | -rw-r--r-- | 24.7 KB |
init_32.c | -rw-r--r-- | 24.5 KB |
init_64.c | -rw-r--r-- | 36.9 KB |
iomap_32.c | -rw-r--r-- | 3.5 KB |
ioremap.c | -rw-r--r-- | 21.8 KB |
kasan_init_64.c | -rw-r--r-- | 8.8 KB |
kaslr.c | -rw-r--r-- | 7.2 KB |
kmmio.c | -rw-r--r-- | 16.1 KB |
mem_encrypt.c | -rw-r--r-- | 23.8 KB |
mem_encrypt_boot.S | -rw-r--r-- | 4.4 KB |
mm_internal.h | -rw-r--r-- | 558 bytes |
mmap.c | -rw-r--r-- | 6.9 KB |
mmio-mod.c | -rw-r--r-- | 11.8 KB |
mpx.c | -rw-r--r-- | 26.0 KB |
numa.c | -rw-r--r-- | 22.7 KB |
numa_32.c | -rw-r--r-- | 3.3 KB |
numa_64.c | -rw-r--r-- | 251 bytes |
numa_emulation.c | -rw-r--r-- | 13.1 KB |
numa_internal.h | -rw-r--r-- | 765 bytes |
pageattr-test.c | -rw-r--r-- | 5.3 KB |
pageattr.c | -rw-r--r-- | 50.4 KB |
pat.c | -rw-r--r-- | 28.2 KB |
pat_internal.h | -rw-r--r-- | 1.5 KB |
pat_rbtree.c | -rw-r--r-- | 6.8 KB |
pf_in.c | -rw-r--r-- | 10.5 KB |
pf_in.h | -rw-r--r-- | 1.4 KB |
pgtable.c | -rw-r--r-- | 16.4 KB |
pgtable_32.c | -rw-r--r-- | 2.2 KB |
physaddr.c | -rw-r--r-- | 2.2 KB |
physaddr.h | -rw-r--r-- | 231 bytes |
pkeys.c | -rw-r--r-- | 6.4 KB |
setup_nx.c | -rw-r--r-- | 1.4 KB |
srat.c | -rw-r--r-- | 2.9 KB |
testmmiotrace.c | -rw-r--r-- | 3.1 KB |
tlb.c | -rw-r--r-- | 18.9 KB |
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...