[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210614155354.630211386@linutronix.de>
Date: Mon, 14 Jun 2021 17:44:17 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Andy Lutomirski <luto@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Fenghua Yu <fenghua.yu@...el.com>,
Tony Luck <tony.luck@...el.com>,
Yu-cheng Yu <yu-cheng.yu@...el.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Borislav Petkov <bp@...e.de>,
Peter Zijlstra <peterz@...radead.org>,
Kan Liang <kan.liang@...ux.intel.com>
Subject: [patch V2 09/52] x86/fpu: Reject invalid MXCSR values in
copy_kernel_to_xstate()
Instead of masking out reserved bits, check them and reject the provided
state as invalid if not zero.
Suggested-by: Andy Lutomirski <luto@...nel.org>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
---
V2: New patch
---
arch/x86/kernel/fpu/xstate.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1166,6 +1166,14 @@ int copy_kernel_to_xstate(struct xregs_s
if (validate_user_xstate_header(&hdr))
return -EINVAL;
+ if (xfeatures_mxcsr_quirk(hdr.xfeatures)) {
+ const u32 *mxcsr = kbuf + offsetof(struct fxregs_state, mxcsr);
+
+ /* Reserved bits in MXCSR must be zero. */
+ if (*mxcsr & ~mxcsr_feature_mask)
+ return -EINVAL;
+ }
+
for (i = 0; i < XFEATURE_MAX; i++) {
u64 mask = ((u64)1 << i);
@@ -1196,9 +1204,6 @@ int copy_kernel_to_xstate(struct xregs_s
*/
xsave->header.xfeatures |= hdr.xfeatures;
- /* mxcsr reserved bits must be masked to zero for historical reasons. */
- xsave->i387.mxcsr &= mxcsr_feature_mask;
-
return 0;
}
Powered by blists - more mailing lists