summaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-02-03 19:25:42 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-02-03 19:25:42 -0500
commit617aebe6a97efa539cc4b8a52adccd89596e6be0 (patch)
tree51c7753c940fd3727b8cc3e93553c57f89d1d9d2 /arch/x86
parent0771ad44a20bc512d1123bac728d3a89ea6febe6 (diff)
parente47e311843dece8073146f3606871280ee9beb87 (diff)
Merge tag 'usercopy-v4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull hardened usercopy whitelisting from Kees Cook: "Currently, hardened usercopy performs dynamic bounds checking on slab cache objects. This is good, but still leaves a lot of kernel memory available to be copied to/from userspace in the face of bugs. To further restrict what memory is available for copying, this creates a way to whitelist specific areas of a given slab cache object for copying to/from userspace, allowing much finer granularity of access control. Slab caches that are never exposed to userspace can declare no whitelist for their objects, thereby keeping them unavailable to userspace via dynamic copy operations. (Note, an implicit form of whitelisting is the use of constant sizes in usercopy operations and get_user()/put_user(); these bypass all hardened usercopy checks since these sizes cannot change at runtime.) This new check is WARN-by-default, so any mistakes can be found over the next several releases without breaking anyone's system. The series has roughly the following sections: - remove %p and improve reporting with offset - prepare infrastructure and whitelist kmalloc - update VFS subsystem with whitelists - update SCSI subsystem with whitelists - update network subsystem with whitelists - update process memory with whitelists - update per-architecture thread_struct with whitelists - update KVM with whitelists and fix ioctl bug - mark all other allocations as not whitelisted - update lkdtm for more sensible test overage" * tag 'usercopy-v4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (38 commits) lkdtm: Update usercopy tests for whitelisting usercopy: Restrict non-usercopy caches to size 0 kvm: x86: fix KVM_XEN_HVM_CONFIG ioctl kvm: whitelist struct kvm_vcpu_arch arm: Implement thread_struct whitelist for hardened usercopy arm64: Implement thread_struct whitelist for hardened usercopy x86: Implement thread_struct whitelist for hardened usercopy fork: Provide usercopy whitelisting for task_struct fork: Define usercopy region in thread_stack slab caches fork: Define usercopy region in mm_struct slab caches net: Restrict unwhitelisted proto caches to size 0 sctp: Copy struct sctp_sock.autoclose to userspace using put_user() sctp: Define usercopy region in SCTP proto slab cache caif: Define usercopy region in caif proto slab cache ip: Define usercopy region in IP proto slab cache net: Define usercopy region in struct proto slab cache scsi: Define usercopy region in scsi_sense_cache slab cache cifs: Define usercopy region in cifs_request slab cache vxfs: Define usercopy region in vxfs_inode slab cache ufs: Define usercopy region in ufs_inode_cache slab cache ...
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/include/asm/processor.h8
-rw-r--r--arch/x86/kvm/x86.c7
3 files changed, 13 insertions, 3 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 72d5149bcaa1..b0771ceabb4b 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -116,6 +116,7 @@ config X86
116 select HAVE_ARCH_MMAP_RND_COMPAT_BITS if MMU && COMPAT 116 select HAVE_ARCH_MMAP_RND_COMPAT_BITS if MMU && COMPAT
117 select HAVE_ARCH_COMPAT_MMAP_BASES if MMU && COMPAT 117 select HAVE_ARCH_COMPAT_MMAP_BASES if MMU && COMPAT
118 select HAVE_ARCH_SECCOMP_FILTER 118 select HAVE_ARCH_SECCOMP_FILTER
119 select HAVE_ARCH_THREAD_STRUCT_WHITELIST
119 select HAVE_ARCH_TRACEHOOK 120 select HAVE_ARCH_TRACEHOOK
120 select HAVE_ARCH_TRANSPARENT_HUGEPAGE 121 select HAVE_ARCH_TRANSPARENT_HUGEPAGE
121 select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD if X86_64 122 select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD if X86_64
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index efbde088a718..6207f2f740b6 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -507,6 +507,14 @@ struct thread_struct {
507 */ 507 */
508}; 508};
509 509
510/* Whitelist the FPU state from the task_struct for hardened usercopy. */
511static inline void arch_thread_struct_whitelist(unsigned long *offset,
512 unsigned long *size)
513{
514 *offset = offsetof(struct thread_struct, fpu.state);
515 *size = fpu_kernel_xstate_size;
516}
517
510/* 518/*
511 * Thread-synchronous status. 519 * Thread-synchronous status.
512 * 520 *
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c53298dfbf50..5040ff9de6ab 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4237,13 +4237,14 @@ set_identity_unlock:
4237 mutex_unlock(&kvm->lock); 4237 mutex_unlock(&kvm->lock);
4238 break; 4238 break;
4239 case KVM_XEN_HVM_CONFIG: { 4239 case KVM_XEN_HVM_CONFIG: {
4240 struct kvm_xen_hvm_config xhc;
4240 r = -EFAULT; 4241 r = -EFAULT;
4241 if (copy_from_user(&kvm->arch.xen_hvm_config, argp, 4242 if (copy_from_user(&xhc, argp, sizeof(xhc)))
4242 sizeof(struct kvm_xen_hvm_config)))
4243 goto out; 4243 goto out;
4244 r = -EINVAL; 4244 r = -EINVAL;
4245 if (kvm->arch.xen_hvm_config.flags) 4245 if (xhc.flags)
4246 goto out; 4246 goto out;
4247 memcpy(&kvm->arch.xen_hvm_config, &xhc, sizeof(xhc));
4247 r = 0; 4248 r = 0;
4248 break; 4249 break;
4249 } 4250 }