forked from Minki/linux
x86/fpu: Preserve supervisor states in sanitize_restored_user_xstate()
sanitize_restored_user_xstate() preserves the supervisor states only
when the fx_only argument is zero, which allows unprivileged user space
to put supervisor states back into init state.
Preserve them unconditionally.
[ bp: Fix a typo or two in the text. ]
Fixes: 5d6b6a6f9b
("x86/fpu/xstate: Update sanitize_restored_xstate() for supervisor xstates")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20210618143444.438635017@linutronix.de
This commit is contained in:
parent
13311e7425
commit
9301982c42
@ -221,28 +221,18 @@ sanitize_restored_user_xstate(union fpregs_state *state,
|
|||||||
|
|
||||||
if (use_xsave()) {
|
if (use_xsave()) {
|
||||||
/*
|
/*
|
||||||
* Note: we don't need to zero the reserved bits in the
|
* Clear all feature bits which are not set in
|
||||||
* xstate_header here because we either didn't copy them at all,
|
* user_xfeatures and clear all extended features
|
||||||
* or we checked earlier that they aren't set.
|
* for fx_only mode.
|
||||||
*/
|
*/
|
||||||
|
u64 mask = fx_only ? XFEATURE_MASK_FPSSE : user_xfeatures;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 'user_xfeatures' might have bits clear which are
|
* Supervisor state has to be preserved. The sigframe
|
||||||
* set in header->xfeatures. This represents features that
|
* restore can only modify user features, i.e. @mask
|
||||||
* were in init state prior to a signal delivery, and need
|
* cannot contain them.
|
||||||
* to be reset back to the init state. Clear any user
|
|
||||||
* feature bits which are set in the kernel buffer to get
|
|
||||||
* them back to the init state.
|
|
||||||
*
|
|
||||||
* Supervisor state is unchanged by input from userspace.
|
|
||||||
* Ensure supervisor state bits stay set and supervisor
|
|
||||||
* state is not modified.
|
|
||||||
*/
|
*/
|
||||||
if (fx_only)
|
header->xfeatures &= mask | xfeatures_mask_supervisor();
|
||||||
header->xfeatures = XFEATURE_MASK_FPSSE;
|
|
||||||
else
|
|
||||||
header->xfeatures &= user_xfeatures |
|
|
||||||
xfeatures_mask_supervisor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_fxsr()) {
|
if (use_fxsr()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user