From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Hansen Subject: Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads Date: Fri, 12 Oct 2018 10:54:05 -0700 Message-ID: <39e0a55f-4920-cfde-9bef-09c51109d211@linux.intel.com> References: <20181004140547.13014-1-bigeasy@linutronix.de> <20181004140547.13014-6-bigeasy@linutronix.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: x86@kernel.org, Andy Lutomirski , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org, "Jason A. Donenfeld" , Rik van Riel To: Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org Return-path: In-Reply-To: <20181004140547.13014-6-bigeasy@linutronix.de> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 10/04/2018 07:05 AM, Sebastian Andrzej Siewior wrote: > The PKRU value is not set for kernel threads because they do not have > the ->initialized value set. As a result the kernel thread has a random > PKRU value set which it inherits from the previous task. > It has been suggested by Paolo Bonzini to set it for kernel threads, too > because it might be a fix. > I *think* this is not required because the kernel threads don't copy > data to/from userland and don't have access to any userspace mm in > general. > However there is this use_mm(). If we gain a mm by use_mm() we don't > have a matching PKRU value because those are per thread. It has been > suggested to use 0 as the PKRU value but this would bypass PKRU. > > Set the initial (default) PKRU value for kernel threads. We might want to do this for cleanliness reasons... Maybe. But this *should* have no practical effects. Kernel threads have no real 'mm' and no user pages. They should not have do access to user mappings. Protection keys *only* apply to user mappings. Thus, logically, they should never be affected by PKRU values. So I'm kinda missing the point of the patch.