From patchwork Fri Nov 2 19:13:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Heimes X-Patchwork-Id: 992523 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42msF92ktTzB4Ns; Sat, 3 Nov 2018 06:14:05 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gIetM-0008Dh-74; Fri, 02 Nov 2018 19:14:00 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gIetK-0008Db-DA for kernel-team@lists.ubuntu.com; Fri, 02 Nov 2018 19:13:58 +0000 Received: from mail-lj1-f200.google.com ([209.85.208.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1gIetK-0004SL-4g for kernel-team@lists.ubuntu.com; Fri, 02 Nov 2018 19:13:58 +0000 Received: by mail-lj1-f200.google.com with SMTP id q185-v6so939069ljb.14 for ; Fri, 02 Nov 2018 12:13:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=QajZjX/CALLwWOcDIOdyZ7vPjudKsIKxW2m2EZYi4Bg=; b=LFbD5PD1bh6j8fwiRwYJV8f/KPHFDC3pkX+9oQknVwSusd1SG7Qvut6xycSpkl09WL RrVU8vET1zWT389PCQz/ug8MhlGQHDY2kglmONMJCLppRsKxsDrwJwNypQn5du70l6wS 36mAonWkAir0wCQl3kOEgaD5/CTnL+dfO1+DyBbpRP9Lg0Qwb4jlvjsZjQEz5SowkxvI EIZ81QXZug9SlvPFiQ/uAswqiIwStSNLHB6cKE0wu3tQOgu5wwQnOf5SFhwYZid7Gar1 kqqe/3FAO9SupB3+QEu0HAh1BoVazWIUI4TPtxEk9Jsr0ojhB6xrmFiHmkjA/ZjcifjS YxFQ== X-Gm-Message-State: AGRZ1gJuQ2JFvNDzqnaq/y5YfBvDUE7VIaOx+SFT6tivL0vZirtT2Cjz yOo9oJhLkEhapBjIH2S6EMC80E7QUdW7VgdUxYL1+3M1FQYyJdsc5IqK0zcRcMXUHQgQywLHVqs skeaq7TIsvHX5R2US82b8Uev7n+5jJ7Y9/TvShdwQmLrg/HiQ9Jsx1rf2KA== X-Received: by 2002:a2e:9715:: with SMTP id r21-v6mr7020236lji.30.1541186037277; Fri, 02 Nov 2018 12:13:57 -0700 (PDT) X-Google-Smtp-Source: AJdET5cbGFmJUDMnHxcvqm6QR1zZaGbpBdorLOdMNdUruKSO2/2MCgkG7Bz5lVJTg82iwW2IxiMLQbIfq3Stu91ytaU= X-Received: by 2002:a2e:9715:: with SMTP id r21-v6mr7020223lji.30.1541186036953; Fri, 02 Nov 2018 12:13:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Frank Heimes Date: Fri, 2 Nov 2018 20:13:45 +0100 Message-ID: Subject: [SRU][Bionic][PATCH 1/1] s390/kvm: fix deadlock when killed by oom To: kernel-team@lists.ubuntu.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Claudio Imbrenda BugLink: http://bugs.launchpad.net/bugs/1800849 When the oom killer kills a userspace process in the page fault handler while in guest context, the fault handler fails to release the mm_sem if the FAULT_FLAG_RETRY_NOWAIT option is set. This leads to a deadlock when tearing down the mm when the process terminates. This bug can only happen when pfault is enabled, so only KVM clients are affected. The problem arises in the rare cases in which handle_mm_fault does not release the mm_sem. This patch fixes the issue by manually releasing the mm_sem when needed. Fixes: 24eb3a824c4f3 ("KVM: s390: Add FAULT_FLAG_RETRY_NOWAIT for guest fault") Cc: # 3.15+ Signed-off-by: Claudio Imbrenda Signed-off-by: Martin Schwidefsky (cherry picked from commit 306d6c49ac9ded11114cb53b0925da52f2c2ada1) Signed-off-by: Frank Heimes Acked-by: Stefan Bader --- if (unlikely(fault & VM_FAULT_ERROR)) diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index e074480..4cc3f06 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -502,6 +502,8 @@ static inline int do_exception(struct pt_regs *regs, int access) /* No reason to continue if interrupted by SIGKILL. */ if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) { fault = VM_FAULT_SIGNAL; + if (flags & FAULT_FLAG_RETRY_NOWAIT) + goto out_up; goto out; }