All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Thomas Gleixner" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@suse.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Rik van Riel <riel@surriel.com>,
	stable@vger.kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org
Subject: [tip: x86/urgent] x86/process: Check PF_KTHREAD and not current->mm for kernel threads
Date: Wed, 09 Jun 2021 14:46:47 -0000	[thread overview]
Message-ID: <162325000736.29796.12036319105894610527.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20210608144345.912645927@linutronix.de>

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     12f7764ac61200e32c916f038bdc08f884b0b604
Gitweb:        https://git.kernel.org/tip/12f7764ac61200e32c916f038bdc08f884b0b604
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Tue, 08 Jun 2021 16:36:20 +02:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Wed, 09 Jun 2021 10:39:04 +02:00

x86/process: Check PF_KTHREAD and not current->mm for kernel threads

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: 0cecca9d03c9 ("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
---
 arch/x86/include/asm/fpu/internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
index ceeba9f..18382ac 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -578,7 +578,7 @@ static inline void switch_fpu_finish(struct fpu *new_fpu)
 	 * PKRU state is switched eagerly because it needs to be valid before we
 	 * return to userland e.g. for a copy_to_user() operation.
 	 */
-	if (current->mm) {
+	if (!(current->flags & PF_KTHREAD)) {
 		pk = get_xsave_addr(&new_fpu->state.xsave, XFEATURE_PKRU);
 		if (pk)
 			pkru_val = pk->pkru;

  reply	other threads:[~2021-06-09 14:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08 14:36 [patch V3 0/6] x86/fpu: Mop up XSAVES and related damage Thomas Gleixner
2021-06-08 14:36 ` [patch V3 1/6] x86/fpu: Prevent state corruption in __fpu__restore_sig() Thomas Gleixner
2021-06-09 14:46   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2021-06-08 14:36 ` [patch V3 2/6] x86/fpu: Invalidate FPU state after a failed XRSTOR from a user buffer Thomas Gleixner
2021-06-09 14:46   ` [tip: x86/urgent] " tip-bot2 for Andy Lutomirski
2021-06-08 14:36 ` [patch V3 3/6] x86/process: Check PF_KTHREAD and not current->mm for kernel threads Thomas Gleixner
2021-06-09 14:46   ` tip-bot2 for Thomas Gleixner [this message]
2021-06-10 17:10   ` Andy Lutomirski
2021-06-10 20:54     ` Thomas Gleixner
2021-06-11  1:04       ` Andy Lutomirski
2021-06-08 14:36 ` [patch V3 4/6] x86/pkru: Make PKRU=0 actually work Thomas Gleixner
2021-06-08 15:40   ` Borislav Petkov
2021-06-08 19:15     ` Thomas Gleixner
2021-06-08 20:06       ` Borislav Petkov
2021-06-08 16:06   ` Dave Hansen
2021-06-08 19:06     ` Thomas Gleixner
2021-06-08 21:37   ` Babu Moger
2021-06-09 14:46   ` [tip: x86/urgent] x86/pkru: Write hardware init value to PKRU when xstate is init tip-bot2 for Thomas Gleixner
2021-06-08 14:36 ` [patch V3 5/6] x86/fpu: Add address range checks to copy_user_to_xstate() Thomas Gleixner
2021-06-09 12:56   ` [tip: x86/fpu] " tip-bot2 for Andy Lutomirski
2021-06-08 14:36 ` [patch V3 6/6] selftests/x86: Test signal frame XSTATE header corruption handling Thomas Gleixner
2021-06-09  8:38   ` David Edmondson
2021-06-09 12:56   ` [tip: x86/fpu] " tip-bot2 for Andy Lutomirski
2021-06-08 16:08 ` [patch V3 0/6] x86/fpu: Mop up XSAVES and related damage Dave Hansen
2021-06-08 18:46 ` Rik van Riel
2021-06-09 19:18 ` [PATCH] x86/fpu: Reset state for all signal restore failures Thomas Gleixner
2021-06-10  6:39   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=162325000736.29796.12036319105894610527.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=bp@suse.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=riel@surriel.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.