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:   Sat, 13 Jan 2018 14:14:14 +0000
From:   David Woodhouse <dwmw2@...radead.org>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Andy Lutomirski <luto@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Borislav Petkov <bp@...en8.de>,
        Laura Abbott <labbott@...hat.com>, X86 ML <x86@...nel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        stable <stable@...r.kernel.org>
Subject: Re: Yet another KPTI regression with 4.14.x series in a VM

On Sat, 2018-01-13 at 14:10 +0100, Peter Zijlstra wrote:
> On Sat, Jan 13, 2018 at 12:30:11PM +0000, David Woodhouse wrote:
> > 
> > On Sat, 2018-01-13 at 13:08 +0100, Peter Zijlstra wrote:
> > > 
> > > 
> > >         ALTERNATIVE "orq $(PTI_SWITCH_PGTABLE_MASK), \scratch_reg",
> > >                     "orq $(PTI_SWITCH_MASK), \scratch_reg", X86_FEATURE_PCID
> > > 
> > > Is not wanting to compile though; probably that whole alternative vs
> > > macro thing again :/
> > Welcome to my world. Try
> > 
> >  ALTERNATIVE __stringify(orq $(PTI_SWITCH_PGTABLE_MASK), \scratch_reg), \
> >              __stringify(orq $(PTI_SWITCH_MASK), \scratch_reg), \
> >              X86_FEATURE_PCID
> Doesn't seem to work, gets literal __stringy() crud in the .s file.

--- a/arch/x86/entry/calling.h
+++ b/arch/x86/entry/calling.h
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/jump_label.h>
+#include <linux/stringify.h>
 #include <asm/unwind_hints.h>
 #include <asm/cpufeatures.h>
 #include <asm/page_types.h>
@@ -222,7 +223,10 @@ For 32-bit we have the following conventions - kernel is built with
 #define THIS_CPU_user_pcid_flush_mask   \
        PER_CPU_VAR(cpu_tlbstate) + TLB_STATE_user_pcid_flush_mask
 
-.macro SWITCH_TO_USER_CR3_NOSTACK scratch_reg:req scratch_reg2:req
+.macro SWITCH_TO_USER_CR3_NOSTACK scratch_reg:req scratch_reg2:req \
+                       pti_sw_mask=__stringify(PTI_SWITCH_MASK) \
+                       pti_sw_pgt_mask=PTI_SWITCH_PGTABLES_MASK
+
        ALTERNATIVE "jmp .Lend_\@", "", X86_FEATURE_PTI
        mov     %cr3, \scratch_reg
 
@@ -247,7 +251,9 @@ For 32-bit we have the following conventions - kernel is built with
 
 .Lwrcr3_\@:
        /* Flip the PGD and ASID to the user version */
-       orq     $(PTI_SWITCH_MASK), \scratch_reg
+       ALTERNATIVE __stringify(orq $\pti_sw_pgt_mask, \scratch_reg),   \
+                   __stringify(orq $\pti_sw_mask, \scratch_reg),               \
+                   X86_FEATURE_PCID
        mov     \scratch_reg, %cr3
 .Lend_\@:
 .endm

Yeah you need to 'stringify' the first of the macro args (pti_sw_mask)
because its default value being in parens confuses the very primitive
.macro arg processing. The last arg is fine.

This shit makes my brain hurt.
Download attachment "smime.p7s" of type "application/x-pkcs7-signature" (5213 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ