Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1739701

[tip:x86/fpu] x86/fpu: Use validate_xstate_header() to validate the xstate_header in copy_kernel_to_xstate()

From tip-bot for Eric Biggers <tipbot@zytor.com>
Newsgroups linux.kernel
Subject [tip:x86/fpu] x86/fpu: Use validate_xstate_header() to validate the xstate_header in copy_kernel_to_xstate()
Date 2017-09-26 10:50 +0200
Message-ID <utTIZ-2nL-11@gated-at.bofh.it> (permalink)
References <utcXp-7Yz-35@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Commit-ID:  af95774b3ca080b0e1e651c0fc7680f3444ddda7
Gitweb:     http://git.kernel.org/tip/af95774b3ca080b0e1e651c0fc7680f3444ddda7
Author:     Eric Biggers <ebiggers@google.com>
AuthorDate: Sun, 24 Sep 2017 12:59:09 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 26 Sep 2017 09:43:47 +0200

x86/fpu: Use validate_xstate_header() to validate the xstate_header in copy_kernel_to_xstate()

Tighten the checks in copy_kernel_to_xstate().

Signed-off-by: Eric Biggers <ebiggers@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Eric Biggers <ebiggers3@gmail.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Kevin Hao <haokexin@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michael Halcrow <mhalcrow@google.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Wanpeng Li <wanpeng.li@hotmail.com>
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
Cc: kernel-hardening@lists.openwall.com
Link: http://lkml.kernel.org/r/20170924105913.9157-7-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/fpu/xstate.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index c97c4a9..325db78 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1138,15 +1138,12 @@ int copy_xstate_to_user(void __user *ubuf, struct xregs_state *xsave, unsigned i
 
 /*
  * Convert from a ptrace standard-format kernel buffer to kernel XSAVES format
- * and copy to the target thread. This is called from xstateregs_set() and
- * there we check the CPU has XSAVES and a whole standard-sized buffer
- * exists.
+ * and copy to the target thread. This is called from xstateregs_set().
  */
 int copy_kernel_to_xstate(struct xregs_state *xsave, const void *kbuf)
 {
 	unsigned int offset, size;
 	int i;
-	u64 allowed_features;
 	struct xstate_header hdr;
 
 	offset = offsetof(struct xregs_state, header);
@@ -1154,12 +1151,7 @@ int copy_kernel_to_xstate(struct xregs_state *xsave, const void *kbuf)
 
 	memcpy(&hdr, kbuf + offset, size);
 
-	/*
-	 * Reject if the user sets any disabled or supervisor features:
-	 */
-	allowed_features = xfeatures_mask & ~XFEATURE_MASK_SUPERVISOR;
-
-	if (hdr.xfeatures & ~allowed_features)
+	if (validate_xstate_header(&hdr))
 		return -EINVAL;
 
 	for (i = 0; i < XFEATURE_MAX; i++) {

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/10] x86/fpu: Split up "x86/fpu: Tighten validation of user-supplied xstate_header" Ingo Molnar <mingo@kernel.org> - 2017-09-24 13:00 +0200
  [PATCH 02/10] x86/fpu: Use validate_xstate_header() to validate the xstate_header in xstateregs_set() Ingo Molnar <mingo@kernel.org> - 2017-09-24 13:00 +0200
    [tip:x86/fpu] x86/fpu: Use validate_xstate_header() to validate the  xstate_header in xstateregs_set() tip-bot for Eric Biggers <tipbot@zytor.com> - 2017-09-26 10:50 +0200
  [PATCH 09/10] x86/fpu: Use validate_xstate_header() to validate the xstate_header in copy_user_to_xstate() Ingo Molnar <mingo@kernel.org> - 2017-09-24 13:00 +0200
    [tip:x86/fpu] x86/fpu: Use validate_xstate_header() to validate the  xstate_header in copy_user_to_xstate() tip-bot for Eric Biggers <tipbot@zytor.com> - 2017-09-26 10:50 +0200
  [PATCH 10/10] x86/fpu: Use using_compacted_format() instead of open coded X86_FEATURE_XSAVES Ingo Molnar <mingo@kernel.org> - 2017-09-24 13:10 +0200
    [tip:x86/fpu] x86/fpu: Use using_compacted_format() instead of open  coded X86_FEATURE_XSAVES tip-bot for Eric Biggers <tipbot@zytor.com> - 2017-09-26 10:50 +0200
  [PATCH 03/10] x86/fpu: Use validate_xstate_header() to validate the xstate_header in sanitize_restored_xstate() Ingo Molnar <mingo@kernel.org> - 2017-09-24 13:10 +0200
    Re: [PATCH 03/10] x86/fpu: Use validate_xstate_header() to validate  the xstate_header in sanitize_restored_xstate() Eric Biggers <ebiggers3@gmail.com> - 2017-09-24 21:00 +0200
      Re: [PATCH 03/10] x86/fpu: Use validate_xstate_header() to validate  the xstate_header in sanitize_restored_xstate() Ingo Molnar <mingo@kernel.org> - 2017-09-24 21:10 +0200
        Re: [PATCH 03/10] x86/fpu: Use validate_xstate_header() to validate  the xstate_header in sanitize_restored_xstate() Eric Biggers <ebiggers3@gmail.com> - 2017-09-24 22:10 +0200
          Re: [PATCH 03/10] x86/fpu: Use validate_xstate_header() to validate  the xstate_header in sanitize_restored_xstate() Ingo Molnar <mingo@kernel.org> - 2017-09-25 08:10 +0200
          Re: [PATCH 03/10] x86/fpu: Use validate_xstate_header() to validate  the xstate_header in sanitize_restored_xstate() Ingo Molnar <mingo@kernel.org> - 2017-09-25 08:20 +0200
            Re: [PATCH 03/10] x86/fpu: Use validate_xstate_header() to validate  the xstate_header in sanitize_restored_xstate() Eric Biggers <ebiggers3@gmail.com> - 2017-09-25 09:30 +0200
              Re: [PATCH 03/10] x86/fpu: Use validate_xstate_header() to validate  the xstate_header in sanitize_restored_xstate() Ingo Molnar <mingo@kernel.org> - 2017-09-25 09:40 +0200
    [tip:x86/fpu] x86/fpu: Use validate_xstate_header() to validate the  xstate_header in __fpu__restore_sig() tip-bot for Eric Biggers <tipbot@zytor.com> - 2017-09-26 10:50 +0200
  [PATCH 07/10] x86/fpu: Copy the full header in copy_user_to_xstate() Ingo Molnar <mingo@kernel.org> - 2017-09-24 13:10 +0200
    [tip:x86/fpu] x86/fpu: Copy the full header in  copy_user_to_xstate() tip-bot for Eric Biggers <tipbot@zytor.com> - 2017-09-26 10:50 +0200
  [PATCH 01/10] x86/fpu: Introduce validate_xstate_header() Ingo Molnar <mingo@kernel.org> - 2017-09-24 13:10 +0200
    [tip:x86/fpu] x86/fpu: Introduce validate_xstate_header() tip-bot for Eric Biggers <tipbot@zytor.com> - 2017-09-26 10:50 +0200
  [PATCH 08/10] x86/fpu: Eliminate the 'xfeatures' local variable in copy_user_to_xstate() Ingo Molnar <mingo@kernel.org> - 2017-09-24 13:10 +0200
    [tip:x86/fpu] x86/fpu: Eliminate the 'xfeatures' local variable in  copy_user_to_xstate() tip-bot for Eric Biggers <tipbot@zytor.com> - 2017-09-26 10:50 +0200
  [PATCH 04/10] x86/fpu: Copy the full state_header in copy_kernel_to_xstate() Ingo Molnar <mingo@kernel.org> - 2017-09-24 13:10 +0200
    [tip:x86/fpu] x86/fpu: Copy the full state_header in  copy_kernel_to_xstate() tip-bot for Eric Biggers <tipbot@zytor.com> - 2017-09-26 10:50 +0200
  [PATCH 06/10] x86/fpu: Use validate_xstate_header() to validate the xstate_header in copy_kernel_to_xstate() Ingo Molnar <mingo@kernel.org> - 2017-09-24 13:10 +0200
    [tip:x86/fpu] x86/fpu: Use validate_xstate_header() to validate the  xstate_header in copy_kernel_to_xstate() tip-bot for Eric Biggers <tipbot@zytor.com> - 2017-09-26 10:50 +0200
  Re: [PATCH 00/10] x86/fpu: Split up "x86/fpu: Tighten validation of  user-supplied xstate_header" Linus Torvalds <torvalds@linux-foundation.org> - 2017-09-24 20:10 +0200
    Re: [PATCH 00/10] x86/fpu: Split up "x86/fpu: Tighten validation of  user-supplied xstate_header" Ingo Molnar <mingo@kernel.org> - 2017-09-24 21:10 +0200
      Re: [RFC GIT PULL] x86 FPU fixes and cleanups Linus Torvalds <torvalds@linux-foundation.org> - 2017-09-26 20:20 +0200

csiph-web