From patchwork Tue Jul 11 14:19:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 107388 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4940199qge; Tue, 11 Jul 2017 07:21:36 -0700 (PDT) X-Received: by 10.99.3.15 with SMTP id 15mr135767pgd.99.1499782896195; Tue, 11 Jul 2017 07:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499782896; cv=none; d=google.com; s=arc-20160816; b=SjFV4Yd2qTqoPo1ptxwSJMuxEcgdP1NdavOUpKRbCCkcM1skb5+Cu4YI8OTl5LzEJm wqM/F8Uc/wEuX3H8+bdWdtCetocaOQK1chio8zb4y7OTya1Eej9y4HMUU7cPhP3l0hOk a8VBXB4yTdVdNoDp+jmytU3eAWwVa13tm+1AfuT1c24rX5uUzs7hHP9zvnyMRAzPGxnF eKsKdL8mQmH7jQapptrOLCmGY1WnwgCAmqQQas1bYUoogcB9Jdgh1qwUnnkcE6bMultT W0SJnizm4+624cl60WaDaiJ5nD9BtNcqL0fj2Mj7MLymNULfnB4sVGEXoNhPRyjzg4Cc qtiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=6MpXiAn1Nb7JxtJ1x+an2BJqVEk4uqT9RXapDBXn/U0=; b=bdsb2g/pWR55ZHE6cIqr8kwCc8NOVE2iyTCMpfYfQ8YIT4Dej+zm4wy0KUOmgkP1F1 Qp5hzbCCr9VAa0SLW/vyFew4QfC+EFb0YhWNZyanGOzZvJhjZfi3gagg8mYZ5hmslWzP Ijw+qDON44a6j6kbdQ7ATfqoNE4iRPTaMog7B347bJTQJJpqs3FQWLj75Qa9kV34f+Ac 2AXYVA3P6XPW3/3Du7yQQxrcZKxRVwlw89m9wHVq2jo4aRIbXXqENBV7X394c3QZGAzW ebDi/TCfyhTVctM/YRtEZkTcQhKZMrnXJNeqy64MAaf/pXLfVZW8X7+MumWdA1J8byiv Ebcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 i1si59970pfa.122.2017.07.11.07.21.35; Tue, 11 Jul 2017 07:21:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932977AbdGKOVH (ORCPT + 25 others); Tue, 11 Jul 2017 10:21:07 -0400 Received: from foss.arm.com ([217.140.101.70]:45542 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932653AbdGKOVF (ORCPT ); Tue, 11 Jul 2017 10:21:05 -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 57C4C15AD; Tue, 11 Jul 2017 07:21:05 -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 3AC873F3E1; Tue, 11 Jul 2017 07:21:03 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Russell King Cc: catalin.marinas@arm.com, james.morse@arm.com, labbott@redhat.com, mark.rutland@arm.com, stable@vger.kernel.org, steve.capper@arm.com, will.deacon@arm.com, viro@zeniv.linux.org.uk, peterz@infradead.org, luto@amacapital.net Subject: [PATCH 2/2] arm: mm: abort uaccess retries upon fatal signal Date: Tue, 11 Jul 2017 15:19:23 +0100 Message-Id: <1499782763-31418-3-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499782763-31418-1-git-send-email-mark.rutland@arm.com> References: <1499782763-31418-1-git-send-email-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When there's a fatal signal pending, arm'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. Signed-off-by: Mark Rutland Reviewed-by: Steve Capper Cc: Russell King Cc: stable@vger.kernel.org --- arch/arm/mm/fault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index ff8b0aa..42f5853 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -315,8 +315,11 @@ static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma) * 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