X-Git-Url: http://git.cascardo.info/?a=blobdiff_plain;f=mm%2Fmemory.c;h=4bfc3a9c3b182ef11728992f580a7591575cdfa6;hb=371a096edf43a8c71844cf71c20765c8b21d07d9;hp=f1a68049edfff60805e2c1019c4d950bfb3e5ed6;hpb=5e1b834b27fb2c27cde33a0752425f11d10c0b2d;p=cascardo%2Flinux.git diff --git a/mm/memory.c b/mm/memory.c index f1a68049edff..4bfc3a9c3b18 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3658,6 +3658,19 @@ int handle_mm_fault(struct vm_area_struct *vma, unsigned long address, mem_cgroup_oom_synchronize(false); } + /* + * This mm has been already reaped by the oom reaper and so the + * refault cannot be trusted in general. Anonymous refaults would + * lose data and give a zero page instead e.g. This is especially + * problem for use_mm() because regular tasks will just die and + * the corrupted data will not be visible anywhere while kthread + * will outlive the oom victim and potentially propagate the date + * further. + */ + if (unlikely((current->flags & PF_KTHREAD) && !(ret & VM_FAULT_ERROR) + && test_bit(MMF_UNSTABLE, &vma->vm_mm->flags))) + ret = VM_FAULT_SIGBUS; + return ret; } EXPORT_SYMBOL_GPL(handle_mm_fault);