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]
Message-ID: <6cd0db14-c9e2-3598-fd10-4b473d78c373@citrix.com>
Date:   Mon, 23 Jan 2023 23:53:30 +0000
From:   Andrew Cooper <Andrew.Cooper3@...rix.com>
To:     Ammar Faizi <ammarfaizi2@...weeb.org>,
        "H. Peter Anvin" <hpa@...or.com>
CC:     Dave Hansen <dave.hansen@...el.com>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "Li, Xin3" <xin3.li@...el.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Peter Zijlstra <peterz@...radead.org>,
        "x86@...nel.org" <x86@...nel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Andrew Cooper <Andrew.Cooper3@...rix.com>
Subject: Re: the x86 sysret_rip test fails on the Intel FRED architecture

On 23/01/2023 9:02 am, Ammar Faizi wrote:
> On 1/23/23 6:45 AM, H. Peter Anvin wrote:
>> static enum regs_ok check_regs_syscall(int syscall,
>>      unsigned long arg1, unsigned long arg2)
>> {
>>
>>      register unsigned long r11 asm("%r11");
>>      unsigned long rcx, rbx, tmp;
>
> tmp is unused.
>
>>      r11 = r11_sentinel;
>>      rcx = rcx_sentinel;
>>
>>      asm volatile("push %3; popf; "
>>               "lea 1f(%%rip),%2; "
>>               "syscall; "
>>               "1:"
>>               : "+r" (r11), "+c" (rcx), "=b" (rbx)
>>               : "g" (rflags_sentinel),
>>                 "a" (syscall), "D" (arg1), "S" (arg2));
>
> BTW, I just realized this "push" is unsafe for userspace code if the
> compiler decides to inline this inside a leaf function that uses the
> redzone.
>
> Reason: Because this "push;" clobbers redzone.
>
> It doesn't always happen, but when that happens it can be confusing to
> debug.
>
> A simple workaround is: just compile it with "-mno-red-zone" flag.

You can't compile userspace like that, unless you recompile and
statically link everything including libc.

The proper way to fix this is to add a "+r" constraint on the stack
pointer, at which point the compiler will arrange for nothing in the
redzone to be live around the asm block.

~Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ