Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2569251ybz; Sun, 26 Apr 2020 23:27:07 -0700 (PDT) X-Google-Smtp-Source: APiQypLXEQ+rCAnDhQSPZfjSHZ34nSW0cEcuJUOJywFJVBk6ixojKAcov7KSbul1OZbxVlSvHLXz X-Received: by 2002:a17:906:724b:: with SMTP id n11mr10800113ejk.355.1587968827591; Sun, 26 Apr 2020 23:27:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587968827; cv=none; d=google.com; s=arc-20160816; b=pd6PtWQJSfo7KHPM/KdnTc01VeT62qV87LvNsC+6UTpLOs6VetBnz+KQjpCuaigdWk XM6DuSWO4m/mB5x0nYCIsHBZK3KBtG+k3T6wBqfX4kFvfO6+Ha2n/2tYGfQg1/yKvqpb xhfO1RaVwjdud+EyG70l7TUeTehEbI5Ig8r3ZwRnE53HMhHbwgeJLnd0kt6bb3+2205H K5Xtv6HNNMmnSduMWDpxtN518KrM1r0C/jxyqUzHwuN5DnEYtE/z0xHY4VuifcpJnt6s WAN0EVxq7ct+TRGkYQIHXCGriPgORy70s2Y4ph0dSHUccIuAmcPn7YGkgDp+bVuhpmD7 GMvg== 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=9AYz9oeCN502bivYfGaxyk962U/sjfv5s1XSp9oMTqo=; b=t65KJsygWVLe7ykR0Ym0LCN/SBkaSXHQ62hs7ANLXx6IJnJkPwXFqos6riKKIhzlTY BWrpgFP1IQMTJd6taGWUoBNV5zFEFRuz1EZ75YP8W7ufmoMgGiALXHY3Twj89TgJImfu McEuK66hcO2jNStugC/EN3q+RL+ibGBswiJ7NsZMGndma1RY6AGjD6e0PI0W6dn+EaZf OHsfBv4iyDEsUOiBIRGuxbGZC8bNuJV8RbQDiMhF4ezho2+TBhQK4rLSTv88Q9dk+SUb bYOAKFjVFzggAVjE5crM/ZtQSxb2pGFmqPXKYFAH7TGAVKpfCi30lBhEjhbIKQfT6ic3 1kGA== 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 a18si7642422ejy.194.2020.04.26.23.26.44; Sun, 26 Apr 2020 23:27:07 -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 S1726575AbgD0GZQ (ORCPT + 99 others); Mon, 27 Apr 2020 02:25:16 -0400 Received: from foss.arm.com ([217.140.110.172]:57178 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726237AbgD0GZP (ORCPT ); Mon, 27 Apr 2020 02:25:15 -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 6999931B; Sun, 26 Apr 2020 23:25:15 -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 A1AF13F73D; Sun, 26 Apr 2020 23:25:12 -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 v2 1/2] arm64/crash_core: Export KERNELPACMASK in vmcoreinfo Date: Mon, 27 Apr 2020 11:55:01 +0530 Message-Id: <1587968702-19996-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. Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Signed-off-by: Amit Daniel Kachhap --- Changes since v1: * Rebased to kernel 5.7-rc3. * 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 | 3 +++ arch/arm64/kernel/crash_core.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/arch/arm64/include/asm/compiler.h b/arch/arm64/include/asm/compiler.h index eece20d..32d5900 100644 --- a/arch/arm64/include/asm/compiler.h +++ b/arch/arm64/include/asm/compiler.h @@ -19,6 +19,9 @@ #define __builtin_return_address(val) \ (void *)(ptrauth_clear_pac((unsigned long)__builtin_return_address(val))) +#else /* !CONFIG_ARM64_PTR_AUTH */ +#define ptrauth_user_pac_mask() 0ULL +#define ptrauth_kernel_pac_mask() 0ULL #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..25cf2ce 100644 --- a/arch/arm64/kernel/crash_core.c +++ b/arch/arm64/kernel/crash_core.c @@ -6,6 +6,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