Skip to content

Commit 75a55bc

Browse files
KAGA-KOKOgregkh
authored andcommitted
x86/process: Check PF_KTHREAD and not current->mm for kernel threads
commit 12f7764 upstream. switch_fpu_finish() checks current->mm as indicator for kernel threads. That's wrong because kernel threads can temporarily use a mm of a user process via kthread_use_mm(). Check the task flags for PF_KTHREAD instead. Fixes: 0cecca9 ("x86/fpu: Eager switch PKRU state") Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Borislav Petkov <bp@suse.de> Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Acked-by: Rik van Riel <riel@surriel.com> Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20210608144345.912645927@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ddaaf38 commit 75a55bc

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎arch/x86/include/asm/fpu/internal.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ static inline void switch_fpu_finish(struct fpu *new_fpu)
578578
* PKRU state is switched eagerly because it needs to be valid before we
579579
* return to userland e.g. for a copy_to_user() operation.
580580
*/
581-
if (current->mm) {
581+
if (!(current->flags & PF_KTHREAD)) {
582582
pk = get_xsave_addr(&new_fpu->state.xsave, XFEATURE_PKRU);
583583
if (pk)
584584
pkru_val = pk->pkru;

0 commit comments

Comments
 (0)