Thread (6 messages) 6 messages, 2 authors, 2018-03-27

[PATCH 33/38] arm64: Implement thread_struct whitelist for hardened usercopy

flat view

From: Dave.Martin@arm.com (Dave P Martin)
Date: 2018-01-15 12:24:59
Also in: linux-arch, linux-fsdevel, linux-mm, lkml, netdev

On Thu, Jan 11, 2018 at 02:03:05AM +0000, Kees Cook wrote:
quoted hunk ↗ jump to hunk
This whitelists the FPU register state portion of the thread_struct for
copying to userspace, instead of the default entire structure.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <redacted>
Cc: Christian Borntraeger <redacted>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: James Morse <james.morse@arm.com>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Dave Martin <Dave.Martin@arm.com>
Cc: zijun_hu <redacted>
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Kees Cook <redacted>
---
 arch/arm64/Kconfig                 | 1 +
 arch/arm64/include/asm/processor.h | 8 ++++++++
 2 files changed, 9 insertions(+)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index a93339f5178f..c84477e6a884 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -90,6 +90,7 @@ config ARM64
      select HAVE_ARCH_MMAP_RND_BITS
      select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT
      select HAVE_ARCH_SECCOMP_FILTER
+     select HAVE_ARCH_THREAD_STRUCT_WHITELIST
      select HAVE_ARCH_TRACEHOOK
      select HAVE_ARCH_TRANSPARENT_HUGEPAGE
      select HAVE_ARCH_VMAP_STACK
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 023cacb946c3..e58a5864ec89 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -113,6 +113,14 @@ struct thread_struct {
      struct debug_info       debug;          /* debugging */
 };

+/* Whitelist the fpsimd_state for copying to userspace. */
+static inline void arch_thread_struct_whitelist(unsigned long *offset,
+                                             unsigned long *size)
+{
+     *offset = offsetof(struct thread_struct, fpsimd_state);
+     *size = sizeof(struct fpsimd_state);
This should be fpsimd_state.user_fpsimd (fpsimd_state.cpu is important
for correctly context switching and not supposed to be user-accessible.
A user copy that encompasses that is definitely a bug).

Cheers
---Dave
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help