Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1856907ybk; Mon, 11 May 2020 06:05:52 -0700 (PDT) X-Google-Smtp-Source: APiQypLlSwxGuvWtAszBnZbQme4iDBwbAh0EK+hOFKlgraf+BdEQCgrLT8BxK2YRdru9/TNA82O6 X-Received: by 2002:aa7:d1c6:: with SMTP id g6mr7301892edp.303.1589202352266; Mon, 11 May 2020 06:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589202352; cv=none; d=google.com; s=arc-20160816; b=DKqZL2yHXl3mQRYPe79o9h1UI19fh/repqXKIekA7Ta3ioTivmpJdYDu7SvQ2De9zT RxBruozN4MYk4eVyHOd4CPJCtAx5AjSGuuEOTMRFpedBWuf8KXsh22NAK1t7ee9P8zmb m76wDGHmn6esvEOShMwa6SIsdPv0SuI+pipbNML//UMRuRsbrxlgtM8H3fL7OjDL3zBl ph7eYPtM+QgVriMgOkXBU0xy4JXndNrLxHK/2LoOLx49mAcFtuhy/U5fPZO1D/7zbfSQ OR72Abl0nwnMw6Oz9+PxlZ1h95Eugw9bfWJSdqDHVNZ/IgjahV4bx0bs0YC69ACto5CE dS0A== 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; bh=GeUviqTiucB4Ef/NBtlA3RbofIR6nwqbmTxTgtZpbpM=; b=vYdCXx5Plum0krWofqz2+1uHlsZghJAH+hYZu30uBjTw7tbxTcypmg5K6huFzQ3uAu uHmd49iCrtpxKjIoDHA/KqUsWZaLG8P6NJuDUkObPpU8+el5VoRJaFDlrfPE9lPM5MY7 xIqQ629Wewn+TVnBFmJQ88EN2OyH/HxYR14/j5TjkFjlPXE2Ho32Wn9vQrE2TH9ez6WP P+0LuEl5cHSOOdTah2xz9u4IuP5CtCuuWMUfglK8E8WlF4HT0gux9GUXpC+oIdvLLpav T8jm0qRGUVGCCD4zL8xl2uuSohubuH2LmkEHfWB9lzVxK7zmug6eqQDoYWawtT9pkl4/ x7fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m20si3046297ejc.411.2020.05.11.06.05.21; Mon, 11 May 2020 06:05:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730034AbgEKNCO (ORCPT + 99 others); Mon, 11 May 2020 09:02:14 -0400 Received: from foss.arm.com ([217.140.110.172]:60036 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726687AbgEKNCN (ORCPT ); Mon, 11 May 2020 09:02:13 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1E454D6E; Mon, 11 May 2020 06:02:13 -0700 (PDT) Received: from a075553-lin.blr.arm.com (a075553-lin.blr.arm.com [10.162.17.24]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 548B83F68F; Mon, 11 May 2020 06:02:10 -0700 (PDT) From: Amit Daniel Kachhap To: linux-arm-kernel@lists.infradead.org Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon , Bhupesh Sharma , Vincenzo Frascino , James Morse , Amit Daniel Kachhap , Mark Rutland Subject: [PATCH v3 1/2] arm64/crash_core: Export KERNELPACMASK in vmcoreinfo Date: Mon, 11 May 2020 18:31:55 +0530 Message-Id: <1589202116-18265-1-git-send-email-amit.kachhap@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Recently arm64 linux kernel added support for Armv8.3-A Pointer Authentication feature. If this feature is enabled in the kernel and the hardware supports address authentication then the return addresses are signed and stored in the stack to prevent ROP kind of attack. Kdump tool will now dump the kernel with signed lr values in the stack. Any user analysis tool for this kernel dump may need the kernel pac mask information in vmcoreinfo to generate the correct return address for stacktrace purpose as well as to resolve the symbol name. This patch is similar to commit ec6e822d1a22d0eef ("arm64: expose user PAC bit positions via ptrace") which exposes pac mask information via ptrace interfaces. The config gaurd ARM64_PTR_AUTH is removed form asm/compiler.h so macros like ptrauth_kernel_pac_mask can be used ungaurded. This config protection is confusing as the pointer authentication feature may be missing at runtime even though this config is present. Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Signed-off-by: Amit Daniel Kachhap --- Changes since v2: * Removed CONFIG_ARM64_PTR_AUTH config guard as suggested by Will. * A commit log change. An implementation of this new KERNELPACMASK vmcoreinfo field used by crash tool can be found here[1]. This change is accepted by crash utility maintainer [2]. [1]: https://www.redhat.com/archives/crash-utility/2020-April/msg00095.html [2]: https://www.redhat.com/archives/crash-utility/2020-April/msg00099.html arch/arm64/include/asm/compiler.h | 4 ---- arch/arm64/kernel/crash_core.c | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/compiler.h b/arch/arm64/include/asm/compiler.h index eece20d..51a7ce8 100644 --- a/arch/arm64/include/asm/compiler.h +++ b/arch/arm64/include/asm/compiler.h @@ -2,8 +2,6 @@ #ifndef __ASM_COMPILER_H #define __ASM_COMPILER_H -#if defined(CONFIG_ARM64_PTR_AUTH) - /* * The EL0/EL1 pointer bits used by a pointer authentication code. * This is dependent on TBI0/TBI1 being enabled, or bits 63:56 would also apply. @@ -19,6 +17,4 @@ #define __builtin_return_address(val) \ (void *)(ptrauth_clear_pac((unsigned long)__builtin_return_address(val))) -#endif /* CONFIG_ARM64_PTR_AUTH */ - #endif /* __ASM_COMPILER_H */ diff --git a/arch/arm64/kernel/crash_core.c b/arch/arm64/kernel/crash_core.c index ca4c3e1..1f646b0 100644 --- a/arch/arm64/kernel/crash_core.c +++ b/arch/arm64/kernel/crash_core.c @@ -5,6 +5,7 @@ */ #include +#include #include void arch_crash_save_vmcoreinfo(void) @@ -16,4 +17,7 @@ void arch_crash_save_vmcoreinfo(void) vmcoreinfo_append_str("NUMBER(PHYS_OFFSET)=0x%llx\n", PHYS_OFFSET); vmcoreinfo_append_str("KERNELOFFSET=%lx\n", kaslr_offset()); + vmcoreinfo_append_str("NUMBER(KERNELPACMASK)=0x%llx\n", + system_supports_address_auth() ? + ptrauth_kernel_pac_mask() : 0); } -- 2.7.4