summaryrefslogtreecommitdiff
path: root/arch/riscv/include
diff options
context:
space:
mode:
authorTong Tiangen <tongtiangen@huawei.com>2021-07-02 07:54:21 +0300
committerPalmer Dabbelt <palmerdabbelt@google.com>2021-08-04 06:58:13 +0300
commit13e47bebbe83f58ddc41d2987567e97c5068a1ec (patch)
tree0dfd912f3db93075e176bff48aa743d0e6df30db /arch/riscv/include
parent67979e927dd053bde3b71128495f651256b3161c (diff)
downloadlinux-13e47bebbe83f58ddc41d2987567e97c5068a1ec.tar.xz
riscv: Implement thread_struct whitelist for hardened usercopy
This whitelists the FPU register state portion of the thread_struct for copying to userspace, instead of the default entire struct. Signed-off-by: Tong Tiangen <tongtiangen@huawei.com> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Diffstat (limited to 'arch/riscv/include')
-rw-r--r--arch/riscv/include/asm/processor.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h
index 021ed64ee608..46b492c78cbb 100644
--- a/arch/riscv/include/asm/processor.h
+++ b/arch/riscv/include/asm/processor.h
@@ -37,6 +37,14 @@ struct thread_struct {
unsigned long bad_cause;
};
+/* Whitelist the fstate from the task_struct for hardened usercopy */
+static inline void arch_thread_struct_whitelist(unsigned long *offset,
+ unsigned long *size)
+{
+ *offset = offsetof(struct thread_struct, fstate);
+ *size = sizeof_field(struct thread_struct, fstate);
+}
+
#define INIT_THREAD { \
.sp = sizeof(init_stack) + (long)&init_stack, \
}