Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3942459pxj; Mon, 21 Jun 2021 09:52:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjgYbpzSVDMhfc+Rxv5h1BREJqrcWWOdc33oOETkGLAl0BVap0qh7TDlSWUQBwYm35BXEv X-Received: by 2002:a50:d943:: with SMTP id u3mr23433210edj.175.1624294347744; Mon, 21 Jun 2021 09:52:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624294347; cv=none; d=google.com; s=arc-20160816; b=WTz8f1cMDBguJVh8Mnb7U9T6ly8vpkH1TQ10HlmYhaTsOWfu8gUHvpHo13OXfCgmYX acoHC+epcAaDRBYdv/6N6TB/gGQHo/J1BOQRKzzf4TpHlvKp2pM4VtyZYihM6K/UvD1P YnC5NhrXQIDh7DKki7BPW+F4Nv3Jgzt5egfR7Hrtn4+a+w6dI4x6Z8H1DYxL20505HrB xPsKjbvh4+eYcYO3Nn7lOJfr2Pl7TBUosJBD0sY5UXIRulvkOjz2rCg7Uwz2tS5OAF64 dsT1r7BNxi2MOfIlr8Q/z1P/mz08ZHY2vpEkgZIvrtTki4M7wIN0RK4Vj39jv72IbYLA fM8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=57jLMj2Jrhu1zq4keDoAl/mCkSc0Ik5ylOjcpxFOo54=; b=XIKEZJM4Yh4QSDcyptEXKLQ8edgR09UZhvOWgNj7CbeuWheiAY0ziPNL9i/lKdz+Oe kRAl6PVXRf28PVEbva12PRN0E/998ZIQetEErW4z+sSWfuktZIUhPnm3IsIZ4E3bd0Cx 5hyqCUoumSSrf4gwySwqNzq9L2YtH4s5WfcpaZK+vZm2KUuX/+uCR5VmFLKmYLbBHiqr MruWYLz2ERDdrJ0+i4pvVhXXAvgyZLZ3jPAk9lFxhlOv4EZgV+VxsyH7e1oz34qb9P8i uAam3vRBwSXXRvgDxMJP21Y4OJhF4n4wdWOD2Zdhtanb8qtC/TQDP2x/tSyGCfuFUicS qKfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Sp48BZjY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o4si5838004edc.544.2021.06.21.09.52.05; Mon, 21 Jun 2021 09:52:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Sp48BZjY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231968AbhFUQvH (ORCPT + 99 others); Mon, 21 Jun 2021 12:51:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:38072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231831AbhFUQrn (ORCPT ); Mon, 21 Jun 2021 12:47:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1BF2061455; Mon, 21 Jun 2021 16:33:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624293214; bh=MRDSB7rhHlkBX0jrG6+LA/MMI6OOLjy29jH3CybOzAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sp48BZjYv0S9C0h4fq4GiL+YWlDD4XAAkpqv0QQSc7criRWaGabqTrZKaMImRZS/4 zye84CGmq/+t+jDQWl/bz3dObzNecnijy3rsxP+ZTz2ZejX0ILuhrNgtADoGA1eb51 ROgCAWdnk322V3c77ebRY7CpOebUlOOjy20yvp9M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , Borislav Petkov , Dave Hansen , Rik van Riel Subject: [PATCH 5.12 141/178] x86/process: Check PF_KTHREAD and not current->mm for kernel threads Date: Mon, 21 Jun 2021 18:15:55 +0200 Message-Id: <20210621154927.572331008@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154921.212599475@linuxfoundation.org> References: <20210621154921.212599475@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner commit 12f7764ac61200e32c916f038bdc08f884b0b604 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: 0cecca9d03c9 ("x86/fpu: Eager switch PKRU state") Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov Acked-by: Dave Hansen Acked-by: Rik van Riel Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20210608144345.912645927@linutronix.de Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/fpu/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- 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(str * 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;