Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4593041pja; Thu, 21 Nov 2019 22:29:05 -0800 (PST) X-Google-Smtp-Source: APXvYqy0yWTQDLWTu6PVk7L4quUcXOKvZjdX2nT9/dJXXm2cRDCls8lSWZXeRwR65y4Ze0eLe12b X-Received: by 2002:a17:906:404d:: with SMTP id y13mr20462412ejj.276.1574404145731; Thu, 21 Nov 2019 22:29:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574404145; cv=none; d=google.com; s=arc-20160816; b=viCxwLltYnHSXvQeX/iAd9qEbVA/NfKa4rOXNxouwKEapUkLGF5LB3eHxTc2IiSCvS /y8DX2vuF3DwmPt24EMn8J/iaCF/EolQPXA6am5953sf84t2JeJRaksMOD71SL++HEad u/UKZgJip+gUtW/1RY8D2XFXXPBub1zmgOdz1XbfU/42pSBYeuZzowzqVs670GPXwyj4 CD9E3HRKJTGXLtocS8/oGRn6hW33QYp4r5zyKon0+VSlDhHaOgxth98YEbeeQg3UJype 7gt/FnVVovr9dCruCqh8gDTbzFfKCl8BzycY5dh2bscQw4qtAghaNYgHVBZzhRTk+nyE +g+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=o3cOZxAi8iLUVuBCvRVTT2U1BlFMiKLCCtKkADXlgT8=; b=oNeq/hK+3XIh0xC2S3IzXLWbExDGAUyWvhI476AXvq0+L4poO9nWUcGcLCbJMXh09K YYuSOMeOtoDB2CXrK4kiXZdF+lPbrgvdl1DDu0WgSCWnbmmqJUAO+L1/ykWtUgX/rHlk 1EY5F5uZiV3L2xryA1bgEcvJvwoS3y1MmlYDEPBzMdllswZVvLueWfoIPKKzWVZWorlb YLucnDFFkE6SPuijb3Nfajh1lZA51xxyO69KqKKVuJHV+Q41x3cMH6LACH7t6wODFZTi NsBiI3abRRIqzYGBVFeZFinQ8loDU5WvoJlACr9eLhmVSIazya0DizDPLzTqHoOFYmua jTrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U4wky5QX; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a26si2307552eje.383.2019.11.21.22.28.39; Thu, 21 Nov 2019 22:29:05 -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=@kernel.org header.s=default header.b=U4wky5QX; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729180AbfKVGYS (ORCPT + 99 others); Fri, 22 Nov 2019 01:24:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:56560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728146AbfKVFv2 (ORCPT ); Fri, 22 Nov 2019 00:51:28 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0ABB22071C; Fri, 22 Nov 2019 05:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401887; bh=qoWiZmhKyc5U9nJDESFCNNEjuf4zfvI/EeR6LBTUUF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U4wky5QXL5bT5ul1T6O3mF6ciRLOCPjdammwpf3o+2yUXIg2xIUZmLkSrfTzsY8KM t9OSWSYJMJ0vYhkzPY42pCOARuBrQ9a7DkKljVix97b3bb1gmyaRPAE6EWbvEAfbTi 5YaiZMhG896abNYmjskBok64gXPlaL76ORJE7fL8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christophe Leroy , Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 4.19 121/219] powerpc/mm: Make NULL pointer deferences explicit on bad page faults. Date: Fri, 22 Nov 2019 00:47:33 -0500 Message-Id: <20191122054911.1750-114-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe Leroy [ Upstream commit 49a502ea23bf9dec47f8f3c3960909ff409cd1bb ] As several other arches including x86, this patch makes it explicit that a bad page fault is a NULL pointer dereference when the fault address is lower than PAGE_SIZE In the mean time, this page makes all bad_page_fault() messages shorter so that they remain on one single line. And it prefixes them by "BUG: " so that they get easily grepped. Signed-off-by: Christophe Leroy [mpe: Avoid pr_cont()] Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/mm/fault.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index 365526ee29b88..6e0ff8b600ced 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -633,21 +633,22 @@ void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig) switch (TRAP(regs)) { case 0x300: case 0x380: - printk(KERN_ALERT "Unable to handle kernel paging request for " - "data at address 0x%08lx\n", regs->dar); + pr_alert("BUG: %s at 0x%08lx\n", + regs->dar < PAGE_SIZE ? "Kernel NULL pointer dereference" : + "Unable to handle kernel data access", regs->dar); break; case 0x400: case 0x480: - printk(KERN_ALERT "Unable to handle kernel paging request for " - "instruction fetch\n"); + pr_alert("BUG: Unable to handle kernel instruction fetch%s", + regs->nip < PAGE_SIZE ? " (NULL pointer?)\n" : "\n"); break; case 0x600: - printk(KERN_ALERT "Unable to handle kernel paging request for " - "unaligned access at address 0x%08lx\n", regs->dar); + pr_alert("BUG: Unable to handle kernel unaligned access at 0x%08lx\n", + regs->dar); break; default: - printk(KERN_ALERT "Unable to handle kernel paging request for " - "unknown fault\n"); + pr_alert("BUG: Unable to handle unknown paging fault at 0x%08lx\n", + regs->dar); break; } printk(KERN_ALERT "Faulting instruction address: 0x%08lx\n", -- 2.20.1