提交 66b2cd21 编写于 作者: W Will Deacon 提交者: Yang Yingliang

arm64: ptr auth: Move per-thread keys from thread_info to thread_struct

mainline inclusion
from v4.20-rc3
commit 84931327
category: feature
bugzilla: 27615
CVE: NA

-------------------------------------------------

We don't need to get at the per-thread keys from assembly at all, so
they can live alongside the rest of the per-thread register state in
thread_struct instead of thread_info.

This will also allow straighforward whitelisting of the keys for
hardened usercopy should we expose them via a ptrace request later on.
Signed-off-by: NWill Deacon <will.deacon@arm.com>

Conflicts:
	arch/arm64/include/asm/thread_info.h
[Zheng Zengkai: fix conflicts caused by skipping the following commit.
396244 arm64: preempt: Provide our own implementation of asm/preempt.h]
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 568902ef
...@@ -80,12 +80,12 @@ static inline unsigned long ptrauth_strip_insn_pac(unsigned long ptr) ...@@ -80,12 +80,12 @@ static inline unsigned long ptrauth_strip_insn_pac(unsigned long ptr)
#define ptrauth_thread_init_user(tsk) \ #define ptrauth_thread_init_user(tsk) \
do { \ do { \
struct task_struct *__ptiu_tsk = (tsk); \ struct task_struct *__ptiu_tsk = (tsk); \
ptrauth_keys_init(&__ptiu_tsk->thread_info.keys_user); \ ptrauth_keys_init(&__ptiu_tsk->thread.keys_user); \
ptrauth_keys_switch(&__ptiu_tsk->thread_info.keys_user); \ ptrauth_keys_switch(&__ptiu_tsk->thread.keys_user); \
} while (0) } while (0)
#define ptrauth_thread_switch(tsk) \ #define ptrauth_thread_switch(tsk) \
ptrauth_keys_switch(&(tsk)->thread_info.keys_user) ptrauth_keys_switch(&(tsk)->thread.keys_user)
#else /* CONFIG_ARM64_PTR_AUTH */ #else /* CONFIG_ARM64_PTR_AUTH */
#define ptrauth_prctl_reset_keys(tsk, arg) (-EINVAL) #define ptrauth_prctl_reset_keys(tsk, arg) (-EINVAL)
......
...@@ -144,6 +144,9 @@ struct thread_struct { ...@@ -144,6 +144,9 @@ struct thread_struct {
unsigned long fault_address; /* fault info */ unsigned long fault_address; /* fault info */
unsigned long fault_code; /* ESR_EL1 value */ unsigned long fault_code; /* ESR_EL1 value */
struct debug_info debug; /* debugging */ struct debug_info debug; /* debugging */
#ifdef CONFIG_ARM64_PTR_AUTH
struct ptrauth_keys keys_user;
#endif
}; };
static inline void arch_thread_struct_whitelist(unsigned long *offset, static inline void arch_thread_struct_whitelist(unsigned long *offset,
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
struct task_struct; struct task_struct;
#include <asm/memory.h> #include <asm/memory.h>
#include <asm/pointer_auth.h>
#include <asm/stack_pointer.h> #include <asm/stack_pointer.h>
#include <asm/types.h> #include <asm/types.h>
...@@ -44,9 +43,6 @@ struct thread_info { ...@@ -44,9 +43,6 @@ struct thread_info {
u64 ttbr0; /* saved TTBR0_EL1 */ u64 ttbr0; /* saved TTBR0_EL1 */
#endif #endif
int preempt_count; /* 0 => preemptable, <0 => bug */ int preempt_count; /* 0 => preemptable, <0 => bug */
#ifdef CONFIG_ARM64_PTR_AUTH
struct ptrauth_keys keys_user;
#endif
}; };
#define thread_saved_pc(tsk) \ #define thread_saved_pc(tsk) \
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
int ptrauth_prctl_reset_keys(struct task_struct *tsk, unsigned long arg) int ptrauth_prctl_reset_keys(struct task_struct *tsk, unsigned long arg)
{ {
struct ptrauth_keys *keys = &tsk->thread_info.keys_user; struct ptrauth_keys *keys = &tsk->thread.keys_user;
unsigned long addr_key_mask = PR_PAC_APIAKEY | PR_PAC_APIBKEY | unsigned long addr_key_mask = PR_PAC_APIAKEY | PR_PAC_APIBKEY |
PR_PAC_APDAKEY | PR_PAC_APDBKEY; PR_PAC_APDAKEY | PR_PAC_APDBKEY;
unsigned long key_mask = addr_key_mask | PR_PAC_APGAKEY; unsigned long key_mask = addr_key_mask | PR_PAC_APGAKEY;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册