Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3931073pxj; Mon, 21 Jun 2021 09:37:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJ0yf9MWJrHAyz5DndCZ97f9u9gg9r99TamC/Kol6KXbQes6eRfS734hwos7i9C2ZdiCPg X-Received: by 2002:a6b:e50c:: with SMTP id y12mr21311422ioc.20.1624293437030; Mon, 21 Jun 2021 09:37:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293437; cv=none; d=google.com; s=arc-20160816; b=RJkSfPOoWYLTrsn1MGH0YVKRFDbyMKxv6VQMj3FJbOpe/KgRj/CZQPQnuJyY0IFrqQ 8l5ctEXYfHEoZoMdLy6EnMe0cvU9L8ckQq4OvX17d19GFPF9vEIT6euOHdgRKaXZZLjD ZfmIVwJBVm0cO41pH7hpkZwmNkmT3/Ic4d+ate+9GRHZTn74fbRK7gun0y4BVrFiB5+v Bz5jg9lhW9iNj1wj66TqUitQNIu/uEWGegXeGfau73t+iBjoCq/KT/W/+q4FhDDxUO1S 4kME8FJvSy7WBKptHTjaLSY7TG++zttF/aLmi8doqGQs6k19RL0sRIY4kBqWenw70smo 0XsA== 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=R8sOKoMygocDeKRf9HofW183cpgO8KSrXrVxxJVhpQ4KtYl9nmAr2fIQP7mIbWae4J BsQS6XcdgF9FZG2vlj9hV3cL3gaphR5nOZC7pQajgTDySXg8hMS2ymWS68Bgcn9Ii60Z 3XkQ3EVnr9g2Z/0j/No0/GS6RDmxlDvs/SkcUhzoCtM57P2pLx4kvOGirxjksMsvz5vH NNyKYk/r8MoYh7sg5zl0CXpgX5ZnGUZLnYQK+y3i8MB4cF9z76p8cHc1Gbf2AnZQa+aT iowTe4H0TOzyZln6V4ubaBHbu+ZQNqGLAgJyRrZAkz+G3NboKNkivPEnvCJAqBc4eOV1 +IGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sVmTX1ab; 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 h2si2209096ilh.91.2021.06.21.09.37.04; Mon, 21 Jun 2021 09:37:17 -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=sVmTX1ab; 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 S232373AbhFUQip (ORCPT + 99 others); Mon, 21 Jun 2021 12:38:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:56050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232877AbhFUQev (ORCPT ); Mon, 21 Jun 2021 12:34:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8D6BB613F6; Mon, 21 Jun 2021 16:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292835; bh=MRDSB7rhHlkBX0jrG6+LA/MMI6OOLjy29jH3CybOzAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sVmTX1abpJiy66dAdcpHnE/MXDFe14MfjVgUoF3CfNe3ovslifSeLivIJyKhZGCKz VeUI+sP9KKr1LZAV6h+qQ0OFnGWuQOREyLLvf4v5t+XKjT/xz+5PKRsb+ObeIH51S5 BmcKO3Ufn2D2VZNqEfNccQo9mvjtWuVOClZLWGI8= 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.10 119/146] x86/process: Check PF_KTHREAD and not current->mm for kernel threads Date: Mon, 21 Jun 2021 18:15:49 +0200 Message-Id: <20210621154918.937006863@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154911.244649123@linuxfoundation.org> References: <20210621154911.244649123@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;