x86/fpu: Copy the full header in copy_user_to_xstate()
authorEric Biggers <[email protected]>
Sun, 24 Sep 2017 10:59:10 +0000 (12:59 +0200)
committerIngo Molnar <[email protected]>
Tue, 26 Sep 2017 07:43:47 +0000 (09:43 +0200)
This is in preparation to verify the full xstate header as supplied by user-space.

Signed-off-by: Eric Biggers <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Eric Biggers <[email protected]>
Cc: Fenghua Yu <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Kevin Hao <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Michael Halcrow <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Wanpeng Li <[email protected]>
Cc: Yu-cheng Yu <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/kernel/fpu/xstate.c

index 325db785033581a411aeb5cdb12fb11b95c7093e..0cd7b73c25e8efe8763c45d6e9dff96eb776d3bd 100644 (file)
@@ -1199,13 +1199,16 @@ int copy_user_to_xstate(struct xregs_state *xsave, const void __user *ubuf)
        int i;
        u64 xfeatures;
        u64 allowed_features;
+       struct xstate_header hdr;
 
        offset = offsetof(struct xregs_state, header);
-       size = sizeof(xfeatures);
+       size = sizeof(hdr);
 
-       if (__copy_from_user(&xfeatures, ubuf + offset, size))
+       if (__copy_from_user(&hdr, ubuf + offset, size))
                return -EFAULT;
 
+       xfeatures = hdr.xfeatures;
+
        /*
         * Reject if the user sets any disabled or supervisor features:
         */