mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-17 07:54:54 +08:00
203b1152d1
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 ec6e822d1a
("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.
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/1589202116-18265-1-git-send-email-amit.kachhap@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
21 lines
731 B
C
21 lines
731 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __ASM_COMPILER_H
|
|
#define __ASM_COMPILER_H
|
|
|
|
/*
|
|
* 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.
|
|
*/
|
|
#define ptrauth_user_pac_mask() GENMASK_ULL(54, vabits_actual)
|
|
#define ptrauth_kernel_pac_mask() GENMASK_ULL(63, vabits_actual)
|
|
|
|
/* Valid for EL0 TTBR0 and EL1 TTBR1 instruction pointers */
|
|
#define ptrauth_clear_pac(ptr) \
|
|
((ptr & BIT_ULL(55)) ? (ptr | ptrauth_kernel_pac_mask()) : \
|
|
(ptr & ~ptrauth_user_pac_mask()))
|
|
|
|
#define __builtin_return_address(val) \
|
|
(void *)(ptrauth_clear_pac((unsigned long)__builtin_return_address(val)))
|
|
|
|
#endif /* __ASM_COMPILER_H */
|