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] [day] [month] [year] [list]
Message-ID: <20190503060434.GA5020@zn.tnic>
Date:   Fri, 3 May 2019 08:04:34 +0200
From:   Borislav Petkov <bp@...en8.de>
To:     Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc:     Qian Cai <cai@....pw>, dave.hansen@...el.com, tglx@...utronix.de,
        x86@...nel.org, "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        luto@...capital.net, hpa@...or.com, mingo@...nel.org
Subject: Re: [PATCH v2] x86/fpu: Fault-in user stack if
 copy_fpstate_to_sigframe() fails

On Thu, May 02, 2019 at 07:11:39PM +0200, Sebastian Andrzej Siewior wrote:
> In the compacted form, XSAVES may save only the XMM+SSE state but skip
> FP (x87 state).
> 
> This is denoted by header->xfeatures = 6. The fastpath
> (copy_fpregs_to_sigframe()) does that but _also_ initialises the FP
> state (cwd to 0x37f, mxcsr as we do, remaining fields to 0).
> 
> The slowpath (copy_xstate_to_user()) leaves most of the FP
> state untouched. Only mxcsr and mxcsr_flags are set due to
> xfeatures_mxcsr_quirk(). Now that XFEATURE_MASK_FP is set
> unconditionally, see
> 
>   04944b793e18 ("x86: xsave: set FP, SSE bits in the xsave header in the user sigcontext"),
> 
> on return from the signal, random garbage is loaded as the FP state.
> 
> Instead of utilizing copy_xstate_to_user(), fault-in the user memory
> and retry the fast path. Ideally, the fast path succeeds on the second
> attempt but may be retried again if the memory is swapped out due
> to memory pressure. If the user memory can not be faulted-in then
> get_user_pages() returns an error so we don't loop forever.
> 
> Fault in memory via get_user_pages_unlocked() so
> copy_fpregs_to_sigframe() succeeds without a fault.
> 
> Fixes: 69277c98f5eef ("x86/fpu: Always store the registers in copy_fpstate_to_sigframe()")
> Reported-by: Kurt Kanzenbach <kurt.kanzenbach@...utronix.de>
> Suggested-by: Dave Hansen <dave.hansen@...el.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
> ---
> v1…v2:
>    - s/get_user_pages()/get_user_pages_unlocked()/
>    - merge cleanups
> 
> I'm posting this all-in-one fix up replacing the original patch so we
> don't have a merge window with known bugs (that is the one that the
> patch was going the fix and the KASAN fallout that it introduced).
> 
>  arch/x86/kernel/fpu/signal.c | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)

Queued to tip:WIP.x86/fpu for some hammering ontop ...

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ