Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp130014pxm; Fri, 25 Feb 2022 05:17:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyc4Shxdeeg2u3V9jSXLbFtzCsj3MOwsZvV5XHF7Df4ktxiQUL9Ai0loiBjT+ABBIrjlpQd X-Received: by 2002:a05:6a00:1a8b:b0:4e1:4151:6637 with SMTP id e11-20020a056a001a8b00b004e141516637mr7760737pfv.23.1645795043563; Fri, 25 Feb 2022 05:17:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645795043; cv=none; d=google.com; s=arc-20160816; b=eeI1yRGWQ8BkiaBCUyjsDzl0G+LTeX934nuAbMWUaREYu1yf+C2AK5ICIzTDamR0DG fHlUbftwcdQXjPwgRgFYehLyHLVMvgYQyZyebXD4jWNcps5ktWKUp6VYQ85MG0ec+2sy CWO8LkpP0uA2Fcz6zQ+XkeqLBXapGavVx/RXWxRCZ7HF3wXfhuUKq0NZyfbKcPrpe1s4 E34Ppx1eFXliwxyrRvBIXT9vQxudLXABDNhxVtamlCrKlTVhAdNxMZEat149UQYooaUL 5Hs5BqS3ipkMQ5TKNiXOuFhQPHlY/mMeLftDKELWklEGTy0p+FVdYOF8Pd4XWAEe8tNj GCAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=lpk6Zx5vLH3g9YKAgyZ0UlC2jGDF3JNRknjCX1k4WEM=; b=bbzEfxop16wHHDfMYTaaP0bINFx3XgcjdCTNO+mFF3HI005BSRs3lEoPuUeejE0y2E aPj+Kx1+W3yYHAjAnfeM4On//zcJGmqcfnCdRE1TBw5b2GIJ+p9gqkjfnroYWU8raTHp xld29W4LSr2YMRJJzC07C7Wx+daxSDP5d5rVTZNS0d5kTNOiWN3tqJtRx0kPECPaIH4e cZLI/6QXfQgXk//X2F3OzjYvowanuYFvI2clAeVD+QObYwbhzU9oSWiJ7emE6L0YfLqN fSjjI6Xx4EekyQ0WAcFppdkmqkn+cbLmsvAtPHbtUQ92qbcAM2N8vAcP9QklYxzOwT6s j4gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kroah.com header.s=fm3 header.b=Ra85Lyrj; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=WAnr+3Rw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020a655783000000b00373cbfb95ccsi1779834pgr.438.2022.02.25.05.17.09; Fri, 25 Feb 2022 05:17:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kroah.com header.s=fm3 header.b=Ra85Lyrj; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=WAnr+3Rw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240428AbiBYMCZ (ORCPT + 99 others); Fri, 25 Feb 2022 07:02:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240420AbiBYMCX (ORCPT ); Fri, 25 Feb 2022 07:02:23 -0500 Received: from new1-smtp.messagingengine.com (new1-smtp.messagingengine.com [66.111.4.221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D70EF3700F; Fri, 25 Feb 2022 04:01:48 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id A104D58020B; Fri, 25 Feb 2022 07:01:46 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 25 Feb 2022 07:01:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; bh=lpk6Zx5vLH3g9YKAgyZ0UlC2jGDF3JNRknjCX1 k4WEM=; b=Ra85Lyrj7DE+Z6BJpWwApGJO/IWX+xfyjyySBy60QGUazgcCk1PpMN sWkr+3Xa8AGMjioiyt4N4fDFvRNP0dEU+XExVYfIkjed76krycxgNx4ZkVDmoKeN 4xAxmQktAFnxbGQU9WwO04kGNUh6bnbs+LJlYESauGSHGK28j8QfTooGkbZnJYjh nchggdgxm+DKs4OyEZa1t25/15zE9GsCV/J++IHGYflfQhzlPEMaOi3ACHQjfe9c Yi9aVboSiu6tDsjaxt10IpTfp2Qt5SXrvcSOP3ajhiaJmPtG9nCbGJEJjZ/x2p2y tyBLV2Y3s6rAtdwYhKm6f9H+2LBsTqPw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=lpk6Zx5vLH3g9YKAg yZ0UlC2jGDF3JNRknjCX1k4WEM=; b=WAnr+3RwsYLSCEC9UhhdxxgWEdIrBKyZo 4OM6RAH4325BbXTKucDgEpM7FdFwf0I6sXWble0jxwGdGFb+701xTfFut3tCszNH dwQw/dljKv7Ub/UQrZVvuQiTuiI/SOCsingGBhwEOGIoSSTbyArw4OoNfCZiANUO tv3soaaAFjqhP8L4d/TWURRjLfj6LKcRobAoXhEyn6qXPmD2jvgCgD7DQEsZnJUo kFdW4kuHjP3ECN2UtpcaHKv/w6Rkpu6wrK2xyPexT/OMDkGQOhPL1mHew75dFzoj RsZTHIASvhjvOmGn/E6uCJZW63xhFrS16IUZVGANmt86CKZRj7gVQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrleeggdefiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepifhrvghgucfm jfcuoehgrhgvgheskhhrohgrhhdrtghomheqnecuggftrfgrthhtvghrnhepveeuheejgf ffgfeivddukedvkedtleelleeghfeljeeiueeggeevueduudekvdetnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepghhrvghgsehkrhhorghhrd gtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 25 Feb 2022 07:01:43 -0500 (EST) Date: Fri, 25 Feb 2022 13:01:02 +0100 From: Greg KH To: Dave Hansen Cc: Brian Geffon , Thomas Gleixner , Willis Kung , Guenter Roeck , Borislav Petkov , Andy Lutomirski , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH stable 5.4,5.10] x86/fpu: Correct pkru/xstate inconsistency Message-ID: References: <543efc25-9b99-53cd-e305-d8b4d917b64b@intel.com> <20220215192233.8717-1-bgeffon@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 24, 2022 at 07:16:17AM -0800, Dave Hansen wrote: > On 2/15/22 11:22, Brian Geffon wrote: > > When eagerly switching PKRU in switch_fpu_finish() it checks that > > current is not a kernel thread as kernel threads will never use PKRU. > > It's possible that this_cpu_read_stable() on current_task > > (ie. get_current()) is returning an old cached value. To resolve this > > reference next_p directly rather than relying on current. > > > > As written it's possible when switching from a kernel thread to a > > userspace thread to observe a cached PF_KTHREAD flag and never restore > > the PKRU. And as a result this issue only occurs when switching > > from a kernel thread to a userspace thread, switching from a non kernel > > thread works perfectly fine because all that is considered in that > > situation are the flags from some other non kernel task and the next fpu > > is passed in to switch_fpu_finish(). > > > > This behavior only exists between 5.2 and 5.13 when it was fixed by a > > rewrite decoupling PKRU from xstate, in: > > commit 954436989cc5 ("x86/fpu: Remove PKRU handling from switch_fpu_finish()") > > > > Unfortunately backporting the fix from 5.13 is probably not realistic as > > it's part of a 60+ patch series which rewrites most of the PKRU handling. > > > > Fixes: 0cecca9d03c9 ("x86/fpu: Eager switch PKRU state") > > Signed-off-by: Brian Geffon > > Signed-off-by: Willis Kung > > Tested-by: Willis Kung > > Cc: # v5.4.x > > Cc: # v5.10.x > > I don't like forking the stable code from mainline. But I also think > that backporting the FPU reworking that changed the PKRU handling is > likely to cause more bugs in stable than it fixes. > > This fix is at least isolated to the protection keys code. > > Acked-by: Dave Hansen now queued up, thanks. greg k-h