This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: rseq/x86: choosing rseq code signature
- From: Peter Zijlstra <peterz at infradead dot org>
- To: Mathieu Desnoyers <mathieu dot desnoyers at efficios dot com>
- Cc: Thomas Gleixner <tglx at linutronix dot de>, Andy Lutomirski <luto at amacapital dot net>, "H. Peter Anvin" <hpa at zytor dot com>, Andi Kleen <andi at firstfloor dot org>, Ingo Molnar <mingo at redhat dot com>, Borislav Petkov <bp at alien8 dot de>, libc-alpha <libc-alpha at sourceware dot org>, linux-kernel <linux-kernel at vger dot kernel dot org>, carlos <carlos at redhat dot com>, x86 <x86 at kernel dot org>
- Date: Wed, 10 Apr 2019 19:57:09 +0200
- Subject: Re: rseq/x86: choosing rseq code signature
- References: <11513896.2624.1554838336494.JavaMail.zimbra@efficios.com> <913288111.2663.1554842622822.JavaMail.zimbra@efficios.com> <20190410065417.GU11158@hirez.programming.kicks-ass.net> <608558890.3157.1554911260089.JavaMail.zimbra@efficios.com>
On Wed, Apr 10, 2019 at 11:47:40AM -0400, Mathieu Desnoyers wrote:
> ----- On Apr 10, 2019, at 2:54 AM, Peter Zijlstra peterz@infradead.org wrote:
>
> > On Tue, Apr 09, 2019 at 04:43:42PM -0400, Mathieu Desnoyers wrote:
> >> +/*
> >> + * RSEQ_SIG is used with the following privileged instructions, which trap in
> >> user-space:
> >> + * x86-32: 0f 01 3d 53 30 05 53 invlpg 0x53053053
> >> + * x86-64: 0f 01 3d 53 30 05 53 invlpg 0x53053053(%rip)
> >> + */
> >
> > Right, and the alternative is: 0f b9 3d $SIG, which decodes to:
> >
> > UD1 $SIG(%rip),%edi
> >
> > which will trap unconditionally. The only problem is that gas will not
> > actually assemble it, but since we're .byte coding it, it doesn't
> > matter.
> >
> > UD1 is specified by both AMD and Intel to take a ModR/M, unlike UD0
> > where they disagree on the ModR/M.
>
> UD1 is even better from a code emulator perspective. It won't have to
> try to emulate invlpg if it sees it.
Some emulators terminate on UD2, not aware of any special UD1 behaviour.
> Byte coding UD1 as your example above gives the following objdump output,
> is it expected ?
>
> objdump --version
> GNU objdump (GNU Binutils for Debian) 2.28
>
> x86-32:
>
> 14: 0f b9 ud1
> 16: 3d 53 30 05 53 cmp $0x53053053,%eax
>
> x86-64:
>
> b: 0f b9 ud1
> d: 3d 53 30 05 53 cmp $0x53053053,%eax
GNU objdump (GNU Binutils for Debian) 2.31.1
0f b9 3d 78 56 34 12 ud1 0x12345678(%rip),%edi
So I suppose your objdump is too old :/