From patchwork Wed Aug 30 08:27:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 111279 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp559263ybm; Wed, 30 Aug 2017 01:28:24 -0700 (PDT) X-Received: by 10.84.217.8 with SMTP id o8mr983106pli.111.1504081704558; Wed, 30 Aug 2017 01:28:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504081704; cv=none; d=google.com; s=arc-20160816; b=vMVCCDa3NO4n3BVivYQQRVYp6BuoLoYDDxmOZwIoVaLLBtFN9qxjPuE9m2pR1fl86y P5wM/X2POghjUxOaWY8/Tn9rpqs7eaXNgDuihGQBAQCUVZhnlAoytOV0Cn7rwRTkGD3K GMlJ2w5HeUum+lh9mejeyW0S8Nm0rhFgUgxzZDEXKKWzN/pMA6CZ+wWQY2n4fg1UkSJy eeRwZJtSLg8LXD5WiQ2ScZc5l7afjAiOB8QYSc0LtmKjnUAjZ3noQUNL7D3K+aZOsxRq LLC01UzVXEgYdSfyiKACdfSrEab+sPewQj5u4w5FesfACyANIgA5S0oW1g1nyP2ps7U6 H1XQ== 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=6kNzm/VLlIhpHOmO31ChKigZ+dBy5M4n1nJSZKP1Eco=; b=luyvnkcfRtSqMsfLJp/Yvp48qDffPNXnxE/2VTnzaFt7YsMBcnJzm0Ra+3Y1tavaSE 2W+BvbWYwyVjMm8Est/og0XIqCDyG6xcCTWjLUlmR6exEek9sXXkI6NSZ+koJUKBAbwu zoNneFLBSGdaQWc6GYTbI2zyK36HCwsHDLhGTiQb+7I8UPj6j5HblBvHbknl+GanIXyR AbwKLFEOePyhc/vr+W27HMVq8GM1Xx8ksnSWB5cOvs4LhF7Iak1ihnKd+FI8/qbabWSF 8re7L9LlomyuaZZKp9w5D0NQDSH3X84jKdZgHxxnEQ8LUa14KjUO3+AJxpz1f9T0GToI wpuA== 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 86si3882617pfk.401.2017.08.30.01.28.24; Wed, 30 Aug 2017 01:28:24 -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 S1751295AbdH3I2X (ORCPT + 6 others); Wed, 30 Aug 2017 04:28:23 -0400 Received: from foss.arm.com ([217.140.101.70]:40616 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751282AbdH3I2X (ORCPT ); Wed, 30 Aug 2017 04:28:23 -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 072972B; Wed, 30 Aug 2017 01:28:23 -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 A30AB3F483; Wed, 30 Aug 2017 01:28:21 -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.4.y] arm64: mm: abort uaccess retries upon fatal signal Date: Wed, 30 Aug 2017 09:27:02 +0100 Message-Id: <1504081622-23174-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 a4b4664..7fabf49 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -313,8 +313,11 @@ retry: * 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