lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 07 Jun 2021 16:08:42 +0200
From:   Thomas Gleixner <tglx@...utronix.de>
To:     Dave Hansen <dave.hansen@...el.com>,
        LKML <linux-kernel@...r.kernel.org>
Cc:     x86@...nel.org, Andy Lutomirski <luto@...nel.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Fenghua Yu <fenghua.yu@...el.com>,
        Tony Luck <tony.luck@...el.com>,
        Yu-cheng Yu <yu-cheng.yu@...el.com>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Subject: Re: [patch V2 00/14] x86/fpu: Mop up XSAVES and related damage

On Mon, Jun 07 2021 at 06:36, Dave Hansen wrote:
> On 6/7/21 6:02 AM, Thomas Gleixner wrote:
>> On exec() the kernel sets PKRU to the default value which is as
>> restrictive as possible.
>> 
>> But on sigrestore PKRU when the init optimization is used PKRU is reset
>> to the hardware default (0), which is as permissive as possible:
>> 
>>   1) On XRSTOR from user and the signal handler cleared the PKRU feature
>>      bit in xsave.header.xfeatures. That's true for the fast and the
>>      slow path.
>> 
>>   2) For the fx_only case which loads the init_fpstate (with my fixes
>>      applied that's not longer the case)
>> 
>> So that's inconsistent at best.
>> 
>> As the kernel defines the "init" behaviour of PKRU as non-permissive
>> on exec() it should do so consequently in sigrestore as well.
>
> Agreed.  The kernel has essentially picked its own init value for PKRU,
> separate from the hardware init value.  It should be applied consistently.
>
> By the way, are you talking specifically about the _error_ paths where
> the kernel is unable to XRSTOR the signal XSAVE buffer for some reason,
> and tries to apply either init_fpu or the hardware init state instead?

1) Successful XRSTOR from user if the PKRU feature bit in the
   sigframe xsave.header.xfeatures is cleared. Both fast and slow path.

2) Successful XRSTOR from user if the PKRU feature bit is cleared in
   fx_sw_user.xfeatures as that loads init_fpstate which is busted in
   mainline. Both fast and slow path. Patch 4/14 of this series fixes this.

3) fx_only both in the fast and slow path are broken without 4/14

4) The error handling path (failed restore) is actually doing the right
   thing.

The slow path and the fx_only/fx_sw_user.xfeaturers cases are trivial
to fix.

The fast path not so much because XRSTOR operates directly on the
sigframe and there is no information about the header.xfeatures
content. So to fix this, we need to get header.xfeatures from user
before the XRSTOR and then handle the case then the PKRU bit is clear.

Thanks

        tglx
  





   

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ