提交 78df6be4 编写于 作者: C Chang S. Bae 提交者: Lin Wang

x86/fpu: Reset permission and fpstate on exec()

mainline inclusion
from mainline-v5.16-rc1
commit e61d6310
category: feature
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I590ZC
CVE: NA

Intel-SIG: commit e61d6310 x86/fpu: Reset permission and fpstate on exec().

--------------------------------

On exec(), extended register states saved in the buffer is cleared. With
dynamic features, each task carries variables besides the register states.
The struct fpu has permission information and struct fpstate contains
buffer size and feature masks. They are all dynamically updated with
dynamic features.

Reset the current task's entire FPU data before an exec() so that the new
task starts with default permission and fpstate.

Rename the register state reset function because the old naming confuses as
it does not reset struct fpstate.
Signed-off-by: NChang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: NBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20211021225527.10184-12-chang.seok.bae@intel.comSigned-off-by: NLin Wang <lin.x.wang@intel.com>
上级 e8da61bf
...@@ -544,7 +544,7 @@ static inline void restore_fpregs_from_init_fpstate(u64 features_mask) ...@@ -544,7 +544,7 @@ static inline void restore_fpregs_from_init_fpstate(u64 features_mask)
/* /*
* Reset current->fpu memory state to the init values. * Reset current->fpu memory state to the init values.
*/ */
static void fpu_reset_fpstate(void) static void fpu_reset_fpregs(void)
{ {
struct fpu *fpu = &current->thread.fpu; struct fpu *fpu = &current->thread.fpu;
...@@ -579,7 +579,7 @@ void fpu__clear_user_states(struct fpu *fpu) ...@@ -579,7 +579,7 @@ void fpu__clear_user_states(struct fpu *fpu)
fpregs_lock(); fpregs_lock();
if (!cpu_feature_enabled(X86_FEATURE_FPU)) { if (!cpu_feature_enabled(X86_FEATURE_FPU)) {
fpu_reset_fpstate(); fpu_reset_fpregs();
fpregs_unlock(); fpregs_unlock();
return; return;
} }
...@@ -609,7 +609,8 @@ void fpu__clear_user_states(struct fpu *fpu) ...@@ -609,7 +609,8 @@ void fpu__clear_user_states(struct fpu *fpu)
void fpu_flush_thread(void) void fpu_flush_thread(void)
{ {
fpu_reset_fpstate(); fpstate_reset(&current->thread.fpu);
fpu_reset_fpregs();
} }
/* /*
* Load FPU context before returning to userspace. * Load FPU context before returning to userspace.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册