Skip to content

Commit

Permalink
x86/fpu: Fail ptrace() requests that try to set invalid MXCSR values
Browse files Browse the repository at this point in the history
There is no benefit from accepting and silently changing an invalid MXCSR
value supplied via ptrace().  Instead, return -EINVAL on invalid input.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210623121452.613614842@linutronix.de
  • Loading branch information
Andy Lutomirski authored and Borislav Petkov committed Jun 23, 2021
1 parent 6164331 commit 145e9e0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arch/x86/kernel/fpu/regset.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
if (ret)
return ret;

/* Mask invalid MXCSR bits (for historical reasons). */
newstate.mxcsr &= mxcsr_feature_mask;
/* Do not allow an invalid MXCSR value. */
if (newstate.mxcsr & ~mxcsr_feature_mask)
return -EINVAL;

fpu__prepare_write(fpu);

Expand Down

0 comments on commit 145e9e0

Please sign in to comment.