linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] arm64/crash_core: Export KERNELPACMASK in vmcoreinfo
@ 2020-03-19  7:39 Amit Daniel Kachhap
  2020-03-19  7:39 ` [PATCH 2/2] Documentation/vmcoreinfo: Add documentation for 'KERNELPACMASK' Amit Daniel Kachhap
  0 siblings, 1 reply; 4+ messages in thread
From: Amit Daniel Kachhap @ 2020-03-19  7:39 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kexec, linux-kernel, Bhupesh Sharma, Vincenzo Frascino,
	Mark Rutland, Catalin Marinas, Will Deacon, Amit Daniel Kachhap,
	James Morse, Dave Anderson

ARMv8.3-A mandated feature Pointer Authentication may needs this change.
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.

User tools like "crash" may need the kernel pac mask information to
generate the correct return address for stacktrace purpose.

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 <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Dave Anderson <anderson@redhat.com>
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
---
 
An implementation of this field used by crash tool can be found here [1].

The patches in this series are based on in-kernel Pointer Authentication
patches present for-next tree [2].

[1]: http://linux-arm.org/git?p=crash-ak.git;a=commit;h=1775c6c33bed9269964719b90064b43a24ce97a5
[2]: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/kernel-ptrauth

 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 <linux/crash_core.h>
 #include <asm/memory.h>
+#include <asm/pointer_auth.h>
 
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] Documentation/vmcoreinfo: Add documentation for 'KERNELPACMASK'
  2020-03-19  7:39 [PATCH 1/2] arm64/crash_core: Export KERNELPACMASK in vmcoreinfo Amit Daniel Kachhap
@ 2020-03-19  7:39 ` Amit Daniel Kachhap
  2020-03-19 13:51   ` John Donnelly
  0 siblings, 1 reply; 4+ messages in thread
From: Amit Daniel Kachhap @ 2020-03-19  7:39 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: kexec, linux-kernel, Bhupesh Sharma, Vincenzo Frascino,
	Mark Rutland, Catalin Marinas, Will Deacon, Amit Daniel Kachhap,
	James Morse, Dave Anderson

Add documentation for KERNELPACMASK variable being added to vmcoreinfo.

It indicates the PAC bits mask information of signed kernel pointers if
ARMv8.3-A Pointer Authentication feature is present.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Dave Anderson <anderson@redhat.com>
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
---
 Documentation/admin-guide/kdump/vmcoreinfo.rst | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/admin-guide/kdump/vmcoreinfo.rst b/Documentation/admin-guide/kdump/vmcoreinfo.rst
index 007a6b8..5cc3ee6 100644
--- a/Documentation/admin-guide/kdump/vmcoreinfo.rst
+++ b/Documentation/admin-guide/kdump/vmcoreinfo.rst
@@ -393,6 +393,12 @@ KERNELOFFSET
 The kernel randomization offset. Used to compute the page offset. If
 KASLR is disabled, this value is zero.
 
+KERNELPACMASK
+-------------
+
+Indicates the PAC bits mask information if Pointer Authentication is
+enabled and address authentication feature is present.
+
 arm
 ===
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] Documentation/vmcoreinfo: Add documentation for 'KERNELPACMASK'
  2020-03-19  7:39 ` [PATCH 2/2] Documentation/vmcoreinfo: Add documentation for 'KERNELPACMASK' Amit Daniel Kachhap
@ 2020-03-19 13:51   ` John Donnelly
  2020-03-20 10:26     ` Amit Kachhap
  0 siblings, 1 reply; 4+ messages in thread
From: John Donnelly @ 2020-03-19 13:51 UTC (permalink / raw)
  To: Amit Daniel Kachhap, linux-arm-kernel
  Cc: Mark Rutland, Catalin Marinas, Bhupesh Sharma, kexec,
	linux-kernel, James Morse, Dave Anderson, Vincenzo Frascino,
	Will Deacon

On 3/19/20 2:39 AM, Amit Daniel Kachhap wrote:
> Add documentation for KERNELPACMASK variable being added to vmcoreinfo.
> 
> It indicates the PAC bits mask information of signed kernel pointers if
> ARMv8.3-A Pointer Authentication feature is present.
> 
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: James Morse <james.morse@arm.com>
> Cc: Dave Anderson <anderson@redhat.com>
> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
> ---
>   Documentation/admin-guide/kdump/vmcoreinfo.rst | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/Documentation/admin-guide/kdump/vmcoreinfo.rst b/Documentation/admin-guide/kdump/vmcoreinfo.rst
> index 007a6b8..5cc3ee6 100644
> --- a/Documentation/admin-guide/kdump/vmcoreinfo.rst
> +++ b/Documentation/admin-guide/kdump/vmcoreinfo.rst
> @@ -393,6 +393,12 @@ KERNELOFFSET
>   The kernel randomization offset. Used to compute the page offset. If
>   KASLR is disabled, this value is zero.
>   
> +KERNELPACMASK
> +-------------
> +
> +Indicates the PAC bits mask information if Pointer Authentication is
> +enabled and address authentication feature is present.
> +
>   arm
>   ===
>   
> 
> 


Hi,

Does this require changes to the  makedumpfile or crash utilities ?



-- 
Thank You,
John

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] Documentation/vmcoreinfo: Add documentation for 'KERNELPACMASK'
  2020-03-19 13:51   ` John Donnelly
@ 2020-03-20 10:26     ` Amit Kachhap
  0 siblings, 0 replies; 4+ messages in thread
From: Amit Kachhap @ 2020-03-20 10:26 UTC (permalink / raw)
  To: John Donnelly, linux-arm-kernel
  Cc: Mark Rutland, Catalin Marinas, Bhupesh Sharma, kexec,
	linux-kernel, James Morse, Dave Anderson, Vincenzo Frascino,
	Will Deacon

Hi,

On 3/19/20 7:21 PM, John Donnelly wrote:
> On 3/19/20 2:39 AM, Amit Daniel Kachhap wrote:
>> Add documentation for KERNELPACMASK variable being added to vmcoreinfo.
>>
>> It indicates the PAC bits mask information of signed kernel pointers if
>> ARMv8.3-A Pointer Authentication feature is present.
>>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will@kernel.org>
>> Cc: Mark Rutland <mark.rutland@arm.com>
>> Cc: James Morse <james.morse@arm.com>
>> Cc: Dave Anderson <anderson@redhat.com>
>> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
>> ---
>>   Documentation/admin-guide/kdump/vmcoreinfo.rst | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/Documentation/admin-guide/kdump/vmcoreinfo.rst 
>> b/Documentation/admin-guide/kdump/vmcoreinfo.rst
>> index 007a6b8..5cc3ee6 100644
>> --- a/Documentation/admin-guide/kdump/vmcoreinfo.rst
>> +++ b/Documentation/admin-guide/kdump/vmcoreinfo.rst
>> @@ -393,6 +393,12 @@ KERNELOFFSET
>>   The kernel randomization offset. Used to compute the page offset. If
>>   KASLR is disabled, this value is zero.
>> +KERNELPACMASK
>> +-------------
>> +
>> +Indicates the PAC bits mask information if Pointer Authentication is
>> +enabled and address authentication feature is present.
>> +
>>   arm
>>   ===
>>
>>
> 
> 
> Hi,
> 
> Does this require changes to the  makedumpfile or crash utilities ?

I did the corresponding change in crash tool. The link is mentioned in 
first patch of the series.

Thanks,
Amit Daniel
> 
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-03-20 10:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19  7:39 [PATCH 1/2] arm64/crash_core: Export KERNELPACMASK in vmcoreinfo Amit Daniel Kachhap
2020-03-19  7:39 ` [PATCH 2/2] Documentation/vmcoreinfo: Add documentation for 'KERNELPACMASK' Amit Daniel Kachhap
2020-03-19 13:51   ` John Donnelly
2020-03-20 10:26     ` Amit Kachhap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).