<div dir="ltr"><div dir="ltr"><div>From: Claudio Imbrenda <<a href="mailto:imbrenda@linux.vnet.ibm.com">imbrenda@linux.vnet.ibm.com</a>></div><div><br></div><div>BugLink: <a href="http://bugs.launchpad.net/bugs/1800849">http://bugs.launchpad.net/bugs/1800849</a></div><div><br></div><div>    s390/kvm: fix deadlock when killed by oom</div><div>    </div><div>    When the oom killer kills a userspace process in the page fault handler</div><div>    while in guest context, the fault handler fails to release the mm_sem</div><div>    if the FAULT_FLAG_RETRY_NOWAIT option is set. This leads to a deadlock</div><div>    when tearing down the mm when the process terminates. This bug can only</div><div>    happen when pfault is enabled, so only KVM clients are affected.</div><div>    </div><div>    The problem arises in the rare cases in which handle_mm_fault does not</div><div>    release the mm_sem. This patch fixes the issue by manually releasing</div><div>    the mm_sem when needed.</div><div>    </div><div>    Fixes: 24eb3a824c4f3 ("KVM: s390: Add FAULT_FLAG_RETRY_NOWAIT for guest fault")</div><div>    Cc: <<a href="mailto:stable@vger.kernel.org">stable@vger.kernel.org</a>> # 3.15+</div><div>    Signed-off-by: Claudio Imbrenda <<a href="mailto:imbrenda@linux.vnet.ibm.com">imbrenda@linux.vnet.ibm.com</a>></div><div>    Signed-off-by: Martin Schwidefsky <<a href="mailto:schwidefsky@de.ibm.com">schwidefsky@de.ibm.com</a>></div><div><br></div><div>---</div><div><br></div><div>diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c</div><div>index e074480..4cc3f06 100644</div><div>--- a/arch/s390/mm/fault.c</div><div>+++ b/arch/s390/mm/fault.c</div><div>@@ -502,6 +502,8 @@ static inline int do_exception(struct pt_regs *regs, int access)</div><div>        /* No reason to continue if interrupted by SIGKILL. */</div><div>        if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) {</div><div>                fault = VM_FAULT_SIGNAL;</div><div>+               if (flags & FAULT_FLAG_RETRY_NOWAIT)</div><div>+                       goto out_up;</div><div>                goto out;</div><div>        }</div><div>        if (unlikely(fault & VM_FAULT_ERROR))</div><div><br></div></div></div>