From patchwork Wed Aug 30 08:25:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 111277 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp557408ybm; Wed, 30 Aug 2017 01:26:27 -0700 (PDT) X-Received: by 10.84.216.10 with SMTP id m10mr934652pli.195.1504081587638; Wed, 30 Aug 2017 01:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504081587; cv=none; d=google.com; s=arc-20160816; b=FeJx0+oCv95FpqER/wAB7SF696SrusyLacdvJcJAmyKommnKM14TasjWTCbrowgJov QGW+OU2mf8tFPD0VebKNBz4sjMrrAa+qSlDZmi4wUr2EbyjjR1M+Iav4OpVMxtivzmh0 H9k5CU1VMkl1F5hW3/8uicv1SjyMxqBQ53O9P9npSS0qFrWJZngZhASxIYN4B4t2qd4i 7mSP59/PcGlqw3+GZSFF7Jzj8i4clG3NLtXqdrO/JfBSS4uSGQzwQF/ZHcJTo0PV/wuu U0cCt+ahFDfrnpEGa1CMJop3aCQzaDEQab+ESe78dmUXqUxJVWbaPi3m4pXWcpRNRoEl /Q+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ul4Xj2ALTWU9oTESCt77pIvh5/35fkZM3LnDQUxfa2Y=; b=RVtP98JyqccrFWIrcaBbUgdtKoqpzhTU64ibLVgDTxSVGpY/idrnoa2iEQ11jj/IGG T+gpvgx5tCngWXn51irawGVg4e23L5ElPx/ZRlOkzB2sNREqdiLB9wjgaWGCskWo2E3y UHfWZ0/pyuiBgxCqQwGa6eSaUwMUopyxm/8ItOhDhawN9nHLTb6qPSUQq2+dTSkDu2Vd LlJV7SKGyZSe7E4P7nClBqo1LYJZ0ONMfYEOG6RI9b7VasPelmCTUIaWBN6ljRUwCz2s +IuiepaajCr/4QNCI7nuaTJm40eYA582HPtnwY2+0bWLdmZD6XC7LiS9zQuJv8ZJOGgv iqfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5si4226154plj.716.2017.08.30.01.26.27; Wed, 30 Aug 2017 01:26:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751302AbdH3I00 (ORCPT + 6 others); Wed, 30 Aug 2017 04:26:26 -0400 Received: from foss.arm.com ([217.140.101.70]:40588 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751271AbdH3I00 (ORCPT ); Wed, 30 Aug 2017 04:26:26 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 31C912B; Wed, 30 Aug 2017 01:26:26 -0700 (PDT) Received: from leverpostej.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CC9883F483; Wed, 30 Aug 2017 01:26:24 -0700 (PDT) From: Mark Rutland To: stable@vger.kernel.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, steve.capper@arm.com, james.morse@arm.com, labbott@redhat.com, Mark Rutland Subject: [PATCH v4.12.y] arm64: mm: abort uaccess retries upon fatal signal Date: Wed, 30 Aug 2017 09:25:06 +0100 Message-Id: <1504081506-19464-1-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Commit 289d07a2dc6c6b6f3e4b8a62669320d99dbe6c3d upstream. When there's a fatal signal pending, arm64's do_page_fault() implementation returns 0. The intent is that we'll return to the faulting userspace instruction, delivering the signal on the way. However, if we take a fatal signal during fixing up a uaccess, this results in a return to the faulting kernel instruction, which will be instantly retried, resulting in the same fault being taken forever. As the task never reaches userspace, the signal is not delivered, and the task is left unkillable. While the task is stuck in this state, it can inhibit the forward progress of the system. To avoid this, we must ensure that when a fatal signal is pending, we apply any necessary fixup for a faulting kernel instruction. Thus we will return to an error path, and it is up to that code to make forward progress towards delivering the fatal signal. Cc: Catalin Marinas Cc: Laura Abbott Cc: stable@vger.kernel.org Reviewed-by: Steve Capper Tested-by: Steve Capper Reviewed-by: James Morse Tested-by: James Morse Signed-off-by: Mark Rutland Signed-off-by: Will Deacon --- arch/arm64/mm/fault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 37b95df..3952d5e 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -397,8 +397,11 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, * signal first. We do not need to release the mmap_sem because it * would already be released in __lock_page_or_retry in mm/filemap.c. */ - if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) + if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) { + if (!user_mode(regs)) + goto no_context; return 0; + } /* * Major/minor page fault accounting is only done on the initial