From patchwork Thu Feb 16 01:54:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 94039 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2299529qgi; Wed, 15 Feb 2017 17:55:17 -0800 (PST) X-Received: by 10.99.95.87 with SMTP id t84mr42498434pgb.209.1487210117156; Wed, 15 Feb 2017 17:55:17 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9si5406901pgc.241.2017.02.15.17.55.16; Wed, 15 Feb 2017 17:55:17 -0800 (PST) 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; dkim=pass header.i=@linaro.org; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752127AbdBPByM (ORCPT + 25 others); Wed, 15 Feb 2017 20:54:12 -0500 Received: from mail-pg0-f51.google.com ([74.125.83.51]:32907 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751371AbdBPByK (ORCPT ); Wed, 15 Feb 2017 20:54:10 -0500 Received: by mail-pg0-f51.google.com with SMTP id 204so1441610pge.0 for ; Wed, 15 Feb 2017 17:54:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=RUIY/eoBSX//AfEfJY92SsBnKFSBm7+wh8umwvHxU4s=; b=hmItL10e3PHWsp8yd0isO2Dru6vm0U1HhMWvUnl0JQIZ66fUJRdvF12V83bTgYr5IG Nkd99p9PxdZLLINioaHA+WqmbMqd2ZhXs2IgBaqUT0eqURymyVLB5FzGje1Ox+NejxS1 bjgfOBJbn3I0CwFDGvi8YU1gtxxrHCU9RNSLs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RUIY/eoBSX//AfEfJY92SsBnKFSBm7+wh8umwvHxU4s=; b=DfUq+mOSR4H9XUQy/00+d0mK2at3dj2D61nt48M6AoLifbaUzd3t87ExZVK0VxpFnG rTQ5DTR199yt1/OS98KhgaSEs+7tQdUfhXzcHcg6TRv4bKtQNAkF7Pq4dnpFiJMsbchj CTz9EvDAUTzs/7Io8+n+exgdIW3lj3bETQwXeWHHcmV8a9IODNgUKXbjREcOpDuq8lA1 KMKrjMquP7bKGU6Ba8+JM9uHct2lfG8OGN0El+dv+l9Zlo+EzuWBxop+CLRBIx+S8Ll+ lONMtUEAHwoCreaNTaPRhXO78uE/1DvNFhZayMEYy7V0jAfsS7gSq1LI343uzjl+dlUL 9myg== X-Gm-Message-State: AMke39keXVvei6dc7nGUsZwhIOhnuqzi/W4PmKCt2KiQiG27IWlsDHysa9TGbT5gl1J5h6qE X-Received: by 10.84.136.75 with SMTP id 69mr48326004plk.172.1487210049951; Wed, 15 Feb 2017 17:54:09 -0800 (PST) Received: from localhost.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id 188sm9651065pfg.99.2017.02.15.17.54.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Feb 2017 17:54:09 -0800 (PST) From: Stephen Boyd To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Laura Abbott , Mark Rutland Subject: [PATCH] arm64: print a fault message when attempting to write RO memory Date: Wed, 15 Feb 2017 17:54:08 -0800 Message-Id: <20170216015408.12933-1-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.10.0.297.gf6727b0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a page is marked read only we should print out that fact, instead of printing out that there was a page fault. Right now we get a cryptic error message that something went wrong with an unhandled fault, but we don't evaluate the esr to figure out that it was a read/write permission fault. Instead of seeing: Unable to handle kernel paging request at virtual address ffff000008e460d8 pgd = ffff800003504000 [ffff000008e460d8] *pgd=0000000083473003, *pud=0000000083503003, *pmd=0000000000000000 Internal error: Oops: 9600004f [#1] PREEMPT SMP we'll see: Internal error: Attempting to write read-only memory: 9600004f [#1] PREEMPT SMP Cc: Laura Abbott Cc: Mark Rutland Signed-off-by: Stephen Boyd --- arch/arm64/mm/fault.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.10.0.297.gf6727b0 diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 156169c6981b..752507fa80ec 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -331,6 +331,11 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, if (!search_exception_tables(regs->pc)) die("Accessing user space memory outside uaccess.h routines", regs, esr); + } else if (is_permission_fault(esr, regs)) { + if (esr & ESR_ELx_WNR) + die("Attempting to write read-only memory", regs, esr); + else + die("Attempting to read unreadable memory", regs, esr); } /*