Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1768763ybj; Wed, 6 May 2020 05:06:04 -0700 (PDT) X-Google-Smtp-Source: APiQypK1N9dZLtB7Yk0Nz7q+yfXtrHRpEnhAefOD/Ejf8qhZN3HmxQ8LPZvpWt9O5b2I64FF2+r9 X-Received: by 2002:a05:6402:70c:: with SMTP id w12mr1066738edx.377.1588766764009; Wed, 06 May 2020 05:06:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588766764; cv=none; d=google.com; s=arc-20160816; b=mNLlogwN3HWS6mBLDBWjLc+ZxxPbbFuRqqm0M+cVo0II25JbC8r7MbmMt8K+kyX2db fFHW9XeAhHd2XIfNxQBkIEkxYwZ1ijwsk8I6TR4kLeZr6giXZd5ZKS15MB5fSy/pPTYo +mtW0Mi8eqNkZtWvR0WUpek9UlVWSG3iyZVUOEwBvNFWrz6822QBzCL6qDnSb3B9OUKq KjFf2nPPJRWHvV6SPn8C38bCbsEo6UEY/OVIhXWWs29GhjPco0vRnXbUchvvs7fozLuA JcZ4h+7/Ikk716IP4P/G4+l/kYJn9sGEkjdoXcjByEZoatMQe/1ezFu8UYfjPLGWUXAg fcYQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from; bh=g0s6uVLoQN7JRN3/K8Pr1W7DFTVZLzmjpBFHcXVrQlA=; b=e77XoUigEckaZkDBhRuVgyWOAEnm+C9sUOrkSYQOG8ss6j1ByZARNcft6WiazWAyn/ zhT2/d9Wb1M68F7T4y4YhDi4YoELoRVLATHO4ssgBZfp1+fU8VwYlWUY7sIphvz29feJ oeLCjzcQMuQI8K1QZCLhPkfgHTU4FzEdXL9sy++ct61KS4chIGDWPz+a/mDaadheN72t zVyUUz1pBLAb22I/riCkZrLdFwtoKQEhU2q6fQRXDBetgRsAbPhmVoX/uy2DhIRdi0g+ rgR8VZjzEU8UKLdJdyj1+C4UTeuyAnrPYpAqzfKZTWLJVsWS4/eVMFWHbRW8V9J7IPMu MYTA== 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 u25si958162edy.422.2020.05.06.05.05.36; Wed, 06 May 2020 05:06:03 -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 S1727874AbgEFMDX (ORCPT + 99 others); Wed, 6 May 2020 08:03:23 -0400 Received: from foss.arm.com ([217.140.110.172]:34950 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727805AbgEFMDW (ORCPT ); Wed, 6 May 2020 08:03:22 -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 DAC661FB; Wed, 6 May 2020 05:03:21 -0700 (PDT) Received: from [10.57.31.214] (unknown [10.57.31.214]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 446353F71F; Wed, 6 May 2020 05:03:19 -0700 (PDT) From: Amit Kachhap Subject: Re: [PATCH v2 1/2] arm64/crash_core: Export KERNELPACMASK in vmcoreinfo To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Catalin Marinas , Bhupesh Sharma , Vincenzo Frascino , James Morse , Mark Rutland References: <1587968702-19996-1-git-send-email-amit.kachhap@arm.com> <20200504171741.GD1833@willie-the-truck> Message-ID: Date: Wed, 6 May 2020 17:32:56 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20200504171741.GD1833@willie-the-truck> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Will, On 5/4/20 10:47 PM, Will Deacon wrote: > On Mon, Apr 27, 2020 at 11:55:01AM +0530, Amit Daniel Kachhap wrote: >> 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 > > This doesn't look quite right to me, since you still have to take into > account the case where CONFIG_ARM64_PTR_AUTH=y but the feature is not > available at runtime: Yes agree with you here. However the config gaurd is saving some extra computation for __builtin_return_address. There are some compiler support being added in __builtin_extract_return_address to mask the PAC. Hopefully that will improve this code. In the meantime let it be like this. I can remove this else case and as other users of ptrauth_{kernel,user}_pac_mask(ptrace.c) protect it with a config gaurd there. > >> @@ -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); > > In which case, would it make more sense to define > ptrauth_{kernel,user}_pac_mask() unconditionally? In fact, I'd probably > just remove the guards completely from asm/compiler.h because I think > they're misleading. As answered above. Let me know your opinion. Although I don't have strong reservation in keeping the config gaurd. Thanks, Amit Daniel > > Will > > --->8 > > diff --git a/arch/arm64/include/asm/compiler.h b/arch/arm64/include/asm/compiler.h > index eece20d2c55f..51a7ce87cdfe 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 */ >