Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-19 Thread Dave Hansen
On 10/19/2018 10:37 AM, Andy Lutomirski wrote: >> I think it's much more straightforward to just not enforce pkeys. >> Having this "phantom" value could cause a very odd, nearly >> undebuggable I/O failure. > But now we have the reverse. The IO can work if it’s truly async but, > if the kernel

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-19 Thread Dave Hansen
On 10/19/2018 10:37 AM, Andy Lutomirski wrote: >> I think it's much more straightforward to just not enforce pkeys. >> Having this "phantom" value could cause a very odd, nearly >> undebuggable I/O failure. > But now we have the reverse. The IO can work if it’s truly async but, > if the kernel

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-19 Thread Andy Lutomirski
> On Oct 19, 2018, at 10:01 AM, Dave Hansen wrote: > > On 10/19/2018 09:59 AM, Andy Lutomirski wrote: >>> That looks like a good API in general. The ffs_user_copy_worker that >>> Sebastian mentioned seems to be used by AIO, in which case of course it >>> has to happen in a kernel thread. >>>

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-19 Thread Andy Lutomirski
> On Oct 19, 2018, at 10:01 AM, Dave Hansen wrote: > > On 10/19/2018 09:59 AM, Andy Lutomirski wrote: >>> That looks like a good API in general. The ffs_user_copy_worker that >>> Sebastian mentioned seems to be used by AIO, in which case of course it >>> has to happen in a kernel thread. >>>

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-19 Thread Dave Hansen
On 10/19/2018 09:59 AM, Andy Lutomirski wrote: >> That looks like a good API in general. The ffs_user_copy_worker that >> Sebastian mentioned seems to be used by AIO, in which case of course it >> has to happen in a kernel thread. >> >> But while the API is good, deciding on the desired semantics

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-19 Thread Dave Hansen
On 10/19/2018 09:59 AM, Andy Lutomirski wrote: >> That looks like a good API in general. The ffs_user_copy_worker that >> Sebastian mentioned seems to be used by AIO, in which case of course it >> has to happen in a kernel thread. >> >> But while the API is good, deciding on the desired semantics

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-19 Thread Andy Lutomirski
> On Oct 19, 2018, at 12:44 AM, Paolo Bonzini wrote: > > On 18/10/2018 22:46, Andy Lutomirski wrote: >>> [0] drivers/usb/gadget/function/f_fs.c::ffs_user_copy_worker() >>> >>> Sebastian >> I think we need an entirely new API: >> >> user_mm_ctx_t ctx = user_mm_ctx_get(); >> >> ... >> >>

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-19 Thread Andy Lutomirski
> On Oct 19, 2018, at 12:44 AM, Paolo Bonzini wrote: > > On 18/10/2018 22:46, Andy Lutomirski wrote: >>> [0] drivers/usb/gadget/function/f_fs.c::ffs_user_copy_worker() >>> >>> Sebastian >> I think we need an entirely new API: >> >> user_mm_ctx_t ctx = user_mm_ctx_get(); >> >> ... >> >>

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-19 Thread Paolo Bonzini
On 18/10/2018 22:46, Andy Lutomirski wrote: >> [0] drivers/usb/gadget/function/f_fs.c::ffs_user_copy_worker() >> >> Sebastian > I think we need an entirely new API: > > user_mm_ctx_t ctx = user_mm_ctx_get(); > > ... > > use_user_mm_ctx(ctx); > unuse_user_mm_ctx(ctx); > > ... > >

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-19 Thread Paolo Bonzini
On 18/10/2018 22:46, Andy Lutomirski wrote: >> [0] drivers/usb/gadget/function/f_fs.c::ffs_user_copy_worker() >> >> Sebastian > I think we need an entirely new API: > > user_mm_ctx_t ctx = user_mm_ctx_get(); > > ... > > use_user_mm_ctx(ctx); > unuse_user_mm_ctx(ctx); > > ... > >

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Andy Lutomirski
> On Oct 18, 2018, at 2:24 PM, Sebastian Andrzej Siewior > wrote: > > On 2018-10-18 13:56:24 [-0700], Dave Hansen wrote: >>> But this is not the only loophole: There is ptrace interface which is >>> used by gdb (just checked) and also bypasses PKRU. So… >> >> Bypassing protection keys is

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Andy Lutomirski
> On Oct 18, 2018, at 2:24 PM, Sebastian Andrzej Siewior > wrote: > > On 2018-10-18 13:56:24 [-0700], Dave Hansen wrote: >>> But this is not the only loophole: There is ptrace interface which is >>> used by gdb (just checked) and also bypasses PKRU. So… >> >> Bypassing protection keys is

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Sebastian Andrzej Siewior
On 2018-10-18 13:56:24 [-0700], Dave Hansen wrote: > > But this is not the only loophole: There is ptrace interface which is > > used by gdb (just checked) and also bypasses PKRU. So… > > Bypassing protection keys is not a big deal IMNHO. In places where a > sane one is not readily available,

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Sebastian Andrzej Siewior
On 2018-10-18 13:56:24 [-0700], Dave Hansen wrote: > > But this is not the only loophole: There is ptrace interface which is > > used by gdb (just checked) and also bypasses PKRU. So… > > Bypassing protection keys is not a big deal IMNHO. In places where a > sane one is not readily available,

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Dave Hansen
On 10/18/2018 01:46 PM, Andy Lutomirski wrote: > Setting it to allow-all/none would let the operation always fail or > succeed which might be an improvement in terms of debugging. However it > is hard to judge what the correct behaviour should be. Should fail or > succeed. Succeed. :) > But this

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Dave Hansen
On 10/18/2018 01:46 PM, Andy Lutomirski wrote: > Setting it to allow-all/none would let the operation always fail or > succeed which might be an improvement in terms of debugging. However it > is hard to judge what the correct behaviour should be. Should fail or > succeed. Succeed. :) > But this

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Andy Lutomirski
On Thu, Oct 18, 2018 at 11:25 AM Sebastian Andrzej Siewior wrote: > > On 2018-10-18 09:48:24 [-0700], Andy Lutomirski wrote: > > > On Oct 18, 2018, at 9:26 AM, Sebastian Andrzej Siewior > > > wrote: > > >> On 2018-10-12 11:02:18 [-0700], Andy Lutomirski wrote: > > >> On Fri, Oct 12, 2018 at

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Andy Lutomirski
On Thu, Oct 18, 2018 at 11:25 AM Sebastian Andrzej Siewior wrote: > > On 2018-10-18 09:48:24 [-0700], Andy Lutomirski wrote: > > > On Oct 18, 2018, at 9:26 AM, Sebastian Andrzej Siewior > > > wrote: > > >> On 2018-10-12 11:02:18 [-0700], Andy Lutomirski wrote: > > >> On Fri, Oct 12, 2018 at

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Sebastian Andrzej Siewior
On 2018-10-18 09:48:24 [-0700], Andy Lutomirski wrote: > > On Oct 18, 2018, at 9:26 AM, Sebastian Andrzej Siewior > > wrote: > >> On 2018-10-12 11:02:18 [-0700], Andy Lutomirski wrote: > >> On Fri, Oct 12, 2018 at 10:54 AM Dave Hansen > >>> So I'm kinda missing the point of the patch. > >> > >>

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Sebastian Andrzej Siewior
On 2018-10-18 09:48:24 [-0700], Andy Lutomirski wrote: > > On Oct 18, 2018, at 9:26 AM, Sebastian Andrzej Siewior > > wrote: > >> On 2018-10-12 11:02:18 [-0700], Andy Lutomirski wrote: > >> On Fri, Oct 12, 2018 at 10:54 AM Dave Hansen > >>> So I'm kinda missing the point of the patch. > >> > >>

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Dave Hansen
On 10/18/2018 09:48 AM, Andy Lutomirski wrote: 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

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Dave Hansen
On 10/18/2018 09:48 AM, Andy Lutomirski wrote: 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

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Andy Lutomirski
> On Oct 18, 2018, at 9:26 AM, Sebastian Andrzej Siewior > wrote: > >> On 2018-10-12 11:02:18 [-0700], Andy Lutomirski wrote: >> On Fri, Oct 12, 2018 at 10:54 AM Dave Hansen >> wrote: >>> On 10/04/2018 07:05 AM, Sebastian Andrzej Siewior wrote: The PKRU value is not set for

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Andy Lutomirski
> On Oct 18, 2018, at 9:26 AM, Sebastian Andrzej Siewior > wrote: > >> On 2018-10-12 11:02:18 [-0700], Andy Lutomirski wrote: >> On Fri, Oct 12, 2018 at 10:54 AM Dave Hansen >> wrote: >>> On 10/04/2018 07:05 AM, Sebastian Andrzej Siewior wrote: The PKRU value is not set for

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Sebastian Andrzej Siewior
On 2018-10-12 11:02:18 [-0700], Andy Lutomirski wrote: > On Fri, Oct 12, 2018 at 10:54 AM Dave Hansen > wrote: > > > > 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

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-18 Thread Sebastian Andrzej Siewior
On 2018-10-12 11:02:18 [-0700], Andy Lutomirski wrote: > On Fri, Oct 12, 2018 at 10:54 AM Dave Hansen > wrote: > > > > 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

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-12 Thread Andy Lutomirski
On Fri, Oct 12, 2018 at 10:54 AM Dave Hansen wrote: > > 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

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-12 Thread Andy Lutomirski
On Fri, Oct 12, 2018 at 10:54 AM Dave Hansen wrote: > > 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

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-12 Thread Dave Hansen
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

Re: [PATCH 05/11] x86/fpu: set PKRU state for kernel threads

2018-10-12 Thread Dave Hansen
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