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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200702201755.GO2786714@ZenIV.linux.org.uk>
Date:   Thu, 2 Jul 2020 21:17:55 +0100
From:   Al Viro <viro@...iv.linux.org.uk>
To:     Linus Torvalds <torvalds@...ux-foundation.org>
Cc:     Michael Ellerman <mpe@...erman.id.au>,
        Christophe Leroy <christophe.leroy@....fr>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        the arch/x86 maintainers <x86@...nel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: objtool clac/stac handling change..

On Thu, Jul 02, 2020 at 12:52:27PM -0700, Linus Torvalds wrote:
> On Thu, Jul 2, 2020 at 6:32 AM Michael Ellerman <mpe@...erman.id.au> wrote:
> >
> > Probably the simplest option for us is to just handle it in our
> > unsafe_op_wrap(). I'll try and come up with something tomorrow.
> 
> IMy suggestion was to basically just always handle it in all exception cases.
> 
> And note that IU don't mean the fault handler: obviously page faults
> (or unaligned faults or whatever) can happen while in a user access
> region.
> 
> But I mean any time fixup_exception() triggers.
> 
> For x86, this is in fact particularly natural: it involves just always
> clearing the AC bit in the "struct pt_regs" that fixup_exception()
> gets anyway. We can do it without even bothering with checking for
> CLAC/STAC support, since without it, AC is meaningless in kernel mode
> anyway, but also because doing "user_access_end()" in the exception
> would be pointless: AC is restored by the exception routine, so on x86
> you *have* to do it by just modifying the return state.

What about

static inline int copy_xregs_to_user(struct xregs_state __user *buf)
{
[...]
        stac();
        XSTATE_OP(XSAVE, buf, -1, -1, err);
        clac();
where XSTATE_OP() is
#define XSTATE_OP(op, st, lmask, hmask, err)                            \
        asm volatile("1:" op "\n\t"                                     \
                     "xor %[err], %[err]\n"                             \
                     "2:\n\t"                                           \
                     ".pushsection .fixup,\"ax\"\n\t"                   \
                     "3: movl $-2,%[err]\n\t"                           \
                     "jmp 2b\n\t"                                       \
                     ".popsection\n\t"                                  \
                     _ASM_EXTABLE(1b, 3b)                               \
                     : [err] "=r" (err)                                 \
                     : "D" (st), "m" (*st), "a" (lmask), "d" (hmask)    \
                     : "memory")

Rely upon objtool not noticing that we have, in effect, clac() in a state
where AC is already cleared?  We could massage that thing to take a label,
but it wouldn't be pretty...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ