From patchwork Wed Aug 30 08:26:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 111278 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp558383ybm; Wed, 30 Aug 2017 01:27:30 -0700 (PDT) X-Received: by 10.99.140.78 with SMTP id q14mr745647pgn.189.1504081650306; Wed, 30 Aug 2017 01:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504081650; cv=none; d=google.com; s=arc-20160816; b=EuGJrGMMDOSlu+bR1FwYurEjUd8u5gonCdyu5pX0EudhuhlFfZAAzUaJyQle5WbKsa CmMPsyzS5VDIGCkN9XMku1R164IZIq2for114EkX8poYWeCessOGteEnvSJFWhJn/nIE LOhdJBXwTFlSW9VM3R0gendvIyTwERqyBSSGeByeS1JbH59HYtOThtxIWIj030aaQrVF 7H99yO/vANRctpMXSeOz1zV7mA5BqExsbwGG3bVkT02dYPiLSV1zNgijcmrZ5QXNpvmT ec07O7ViAo6hd7Wn8agOgrbInOp6biDOC1KXRwe74jfJTURNd1YA3Da5cwF9rOsT4zX7 tfKg== 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=rpIIA+vFzYjTC5VP5Tj5CSr8Kn9x1C9ym9W3hTAa+mWdqwo70++aey/vs/+aUEN6hO eOFYmgo+HyUZzbO0AU2p4VBLXWhQKGL/nB5QpHRd+V4dS3CQ+NnxVIwHYuF0BhlaZbny 0mzL2HmkH1V52psxOzE/5MGNuojbReod/76H/eleB98P8dCJFo+Rwz13QQLecNn1jRkp yPZGOM73ix+YR9BGGFNtNIuAvDQupHlziNj04bO45L3tRcWvs9SqPFjOEcflfBmwoNeS r4OlZSVUxU+CRtX7+JsUAH/fm1aQ7qpH8eLfkZOgE8/KcRYWlCmhzLgoGl84a7AZLpdh z8iQ== 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.27.30; Wed, 30 Aug 2017 01:27:30 -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 S1751271AbdH3I13 (ORCPT + 6 others); Wed, 30 Aug 2017 04:27:29 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:40596 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751263AbdH3I13 (ORCPT ); Wed, 30 Aug 2017 04:27:29 -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 EBA682B; Wed, 30 Aug 2017 01:27:28 -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 9387D3F483; Wed, 30 Aug 2017 01:27:27 -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.9.y] arm64: mm: abort uaccess retries upon fatal signal Date: Wed, 30 Aug 2017 09:26:09 +0100 Message-Id: <1504081569-21606-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