Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2290546imm; Mon, 28 May 2018 05:30:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq7h4lBzf5VjkLEhD9RbGalXs1Pcyrk+TIJcvwqWXiItQ8I2CG41yfFGo+gomNYol4iE6/0 X-Received: by 2002:a17:902:7406:: with SMTP id g6-v6mr13156395pll.90.1527510604623; Mon, 28 May 2018 05:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527510604; cv=none; d=google.com; s=arc-20160816; b=DiSAKpUIZBkUjULB0Qy2pNq9NRWHnAce4pJBnbL5h9qjFdHjU45+XHE9VfVTmNrsAv SjI2yjvhjtjnNY5PWtXc1RDrhV0NjcJC72rLNSbuQwz6IWHb+4oHGo8+rFS5p1G1TLGO H03+j/CeJYdw8VGsoNPllwrAgaDHTp/YFa7O4MhjuLHgbcQdlnrY4lGgC61ok08n80Ly GJ6wjfSzVZ1yV14nR1ddAsSSplcZFWyO7xze88mRIgGzPvO3uiL7xznlkFujnPtnXqxZ 8oNq6ybVbj0xg2O6wjDIMR82k3gMiYW77IGQ6xfZXBfWiXI0t3EpcuB50BeLqS5jY2Sa /0NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=fbEZF4XhJglraXjL7Xxu8gHzdT6oLikAkV0Ss0JfdGo=; b=vxW1GNv8WETdJBjt9Wz/V7eFRy5Bye0SQbYPE+y2MEBgbTlcL8f2TfaV09QpLPdqP7 6zzn0DMqLIXao1ZvXEY4HzL/kSm0bzPiJQMv6Ji/RGkGP3hT2Z8eU+5sIwJhatUuWAQi 77AKPA1QShCH6+I2qywJuJc/xiNxYfxhjRNeVWouZ+zf1pXHhBiLuxuPy6fpJ/QLNrjJ J+bX71z3eUr8ih/WqpEiysABdpmwPQ4fsFMhTcjn4u5OVIbIxnaVUpoUpVieztTXqNTx YY7GSR4stH6TB38Mc2Ewa3yq0ssJVH2xnhvORZQ1NN81GMQvxhjPKYJm8PyR6wWRPisE NeAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qXksa6BC; 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 w3-v6si23849322pge.89.2018.05.28.05.29.49; Mon, 28 May 2018 05:30:04 -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; dkim=pass header.i=@kernel.org header.s=default header.b=qXksa6BC; 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 S938815AbeE1M2Z (ORCPT + 99 others); Mon, 28 May 2018 08:28:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:48462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422701AbeE1LAw (ORCPT ); Mon, 28 May 2018 07:00:52 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D4C4520883; Mon, 28 May 2018 11:00:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505252; bh=XdQztErWXm9QFe65TPlAGDonM9c0aruMALkzf4nAvx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qXksa6BCo0kBK3iBi8JDdnx+iWxUXUEaUZFVCBdkmdycs5q2bGrQX299YG1upfjWD 0D9+PVnvF8t1FvKveUZ1IAbi8sauO4dvucD2i+lepoo7RSF+2P7Un1DGq+/aJtp7Ya wBDxcqAhzp9aYdagkNV9wjXT71GQ7O5HDrmtAsVw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Mark Rutland , Ard Biesheuvel , Linus Torvalds , Matt Fleming , Peter Zijlstra , Thomas Gleixner , linux-efi@vger.kernel.org, Ingo Molnar , Sasha Levin Subject: [PATCH 4.14 431/496] efi/arm*: Only register page tables when they exist Date: Mon, 28 May 2018 12:03:36 +0200 Message-Id: <20180528100337.902593455@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Rutland [ Upstream commit 6b31a2fa1e8f7bc6c2a474b4a12dad7a145cf83d ] Currently the arm/arm64 runtime code registers the runtime servies pagetables with ptdump regardless of whether runtime services page tables have been created. As efi_mm.pgd is NULL in these cases, attempting to dump the efi page tables results in a NULL pointer dereference in the ptdump code: /sys/kernel/debug# cat efi_page_tables [ 479.522600] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 479.522715] Mem abort info: [ 479.522764] ESR = 0x96000006 [ 479.522850] Exception class = DABT (current EL), IL = 32 bits [ 479.522899] SET = 0, FnV = 0 [ 479.522937] EA = 0, S1PTW = 0 [ 479.528200] Data abort info: [ 479.528230] ISV = 0, ISS = 0x00000006 [ 479.528317] CM = 0, WnR = 0 [ 479.528317] user pgtable: 4k pages, 48-bit VAs, pgd = 0000000064ab0cb0 [ 479.528449] [0000000000000000] *pgd=00000000fbbe4003, *pud=00000000fb66e003, *pmd=0000000000000000 [ 479.528600] Internal error: Oops: 96000006 [#1] PREEMPT SMP [ 479.528664] Modules linked in: [ 479.528699] CPU: 0 PID: 2457 Comm: cat Not tainted 4.15.0-rc3-00065-g2ad2ee7ecb5c-dirty #7 [ 479.528799] Hardware name: FVP Base (DT) [ 479.528899] pstate: 00400009 (nzcv daif +PAN -UAO) [ 479.528941] pc : walk_pgd.isra.1+0x20/0x1d0 [ 479.529011] lr : ptdump_walk_pgd+0x30/0x50 [ 479.529105] sp : ffff00000bf4bc20 [ 479.529185] x29: ffff00000bf4bc20 x28: 0000ffff9d22e000 [ 479.529271] x27: 0000000000020000 x26: ffff80007b4c63c0 [ 479.529358] x25: 00000000014000c0 x24: ffff80007c098900 [ 479.529445] x23: ffff00000bf4beb8 x22: 0000000000000000 [ 479.529532] x21: ffff00000bf4bd70 x20: 0000000000000001 [ 479.529618] x19: ffff00000bf4bcb0 x18: 0000000000000000 [ 479.529760] x17: 000000000041a1c8 x16: ffff0000082139d8 [ 479.529800] x15: 0000ffff9d3c6030 x14: 0000ffff9d2527f4 [ 479.529924] x13: 00000000000003f3 x12: 0000000000000038 [ 479.530000] x11: 0000000000000003 x10: 0101010101010101 [ 479.530099] x9 : 0000000017e94050 x8 : 000000000000003f [ 479.530226] x7 : 0000000000000000 x6 : 0000000000000000 [ 479.530313] x5 : 0000000000000001 x4 : 0000000000000000 [ 479.530416] x3 : ffff000009069fd8 x2 : 0000000000000000 [ 479.530500] x1 : 0000000000000000 x0 : 0000000000000000 [ 479.530599] Process cat (pid: 2457, stack limit = 0x000000005d1b0e6f) [ 479.530660] Call trace: [ 479.530746] walk_pgd.isra.1+0x20/0x1d0 [ 479.530833] ptdump_walk_pgd+0x30/0x50 [ 479.530907] ptdump_show+0x10/0x20 [ 479.530920] seq_read+0xc8/0x470 [ 479.531023] full_proxy_read+0x60/0x90 [ 479.531100] __vfs_read+0x18/0x100 [ 479.531180] vfs_read+0x88/0x160 [ 479.531267] SyS_read+0x48/0xb0 [ 479.531299] el0_svc_naked+0x20/0x24 [ 479.531400] Code: 91400420 f90033a0 a90707a2 f9403fa0 (f9400000) [ 479.531499] ---[ end trace bfe8e28d8acb2b67 ]--- Segmentation fault Let's avoid this problem by only registering the tables after their successful creation, which is also less confusing when EFI runtime services are not in use. Reported-by: Will Deacon Signed-off-by: Mark Rutland Signed-off-by: Ard Biesheuvel Acked-by: Will Deacon Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20180308080020.22828-2-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efi/arm-runtime.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -54,6 +54,9 @@ static struct ptdump_info efi_ptdump_inf static int __init ptdump_init(void) { + if (!efi_enabled(EFI_RUNTIME_SERVICES)) + return 0; + return ptdump_debugfs_register(&efi_ptdump_info, "efi_page_tables"); } device_initcall(ptdump_init);