From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: peter maydell <peter.maydell@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>,
libc-alpha <libc-alpha@sourceware.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
carlos <carlos@redhat.com>,
richard earnshaw <richard.earnshaw@arm.com>
Subject: Re: rseq/arm32: choosing rseq code signature
Date: Mon, 15 Apr 2019 09:11:30 -0400 (EDT) [thread overview]
Message-ID: <936773156.261.1555333890988.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <CAFEAcA849mmSds9euyvR2uLWqEeA2eedkmcq1O4pT6-S0oK8BA@mail.gmail.com>
----- On Apr 11, 2019, at 3:55 PM, peter maydell peter.maydell@linaro.org wrote:
> On Thu, 11 Apr 2019 at 18:51, Mathieu Desnoyers
> <mathieu.desnoyers@efficios.com> wrote:
>> ----- On Apr 11, 2019, at 12:42 PM, Will Deacon will.deacon@arm.com wrote:
>> > Peter suggests that anything of the form 0xe7fxdefx should trap in both A32
>> > and T32, although it does assemble to UDF; B <imm11> in T16. I'm not sure we
>> > should get too obsessed with trying to encode a signature that universally
>> > decodes to a trap.
>>
>> That's a nice trick.
>>
>> >
>> > Whatever you choose, it would be worth checking that it doesn't clash with
>> > other allocations such as software breakpoints in GDB.
>>
>> GDB seems to have [1] :
>>
>> #define ARM_LE_BREAKPOINT {0xFE,0xDE,0xFF,0xE7}
>> #define ARM_BE_BREAKPOINT {0xE7,0xFF,0xDE,0xFE}
>> #define THUMB_LE_BREAKPOINT {0xbe,0xbe}
>> #define THUMB_BE_BREAKPOINT {0xbe,0xbe}
>>
>> None of which match the value you hint at.
>
> Hmm? The ARM BPs match 0xe7fxdefx when considered with
> the appropriate endianness (clearly somebody has
> been down this line of thought before). Still, as long as
> we pick different values for the 8 bits of freedom we
> have it should be fine.
Right. I selected 0xe7f5def3, which should ensure we are distinct
from gdb's choice.
>
>> /*
>> * RSEQ_SIG uses the udf A32 instruction with an uncommon immediate operand
>> * value 0x5de3. This traps if user-space reaches this instruction by mistake,
>> * and the uncommon operand ensures the kernel does not move the instruction
>> * pointer to attacker-controlled code on rseq abort.
>> *
>> * The instruction pattern in the A32 instruction set is:
>> *
>> * e7f5def3 udf #24035 ; 0x5de3
>> *
>> * This translates to the following instruction pattern in the T16 instruction
>> * set:
>> *
>> * little endian:
>> * def3 udf #243 ; 0xf3
>> * e7f5 b.n <7f5>
>> *
>> * big endian:
>> * e7f5 b.n <7f5>
>> * def3 udf #243 ; 0xf3
>
> Do we really care about big-endian instruction-ordering for Thumb?
> It requires (AIUI) either an ARMv7R CPU which implements and sets
> SCTLR.IE to 1, or a v6-or-earlier CPU using BE32, and it's going to
> be even rarer than normal BE8 big-endian...
I don't think we care enough about it to look for a trick to
turn the branch into something else (which would not branch away from the
udf instruction), but considering this signature will be ABI, it's good to
be thorough documentation-wise and cover all existing cases.
Thoughts ?
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2019-04-15 13:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-09 19:32 rseq/arm32: choosing rseq code signature Mathieu Desnoyers
2019-04-10 20:29 ` Mathieu Desnoyers
2019-04-11 16:42 ` Will Deacon
2019-04-11 17:51 ` Mathieu Desnoyers
2019-04-11 19:55 ` Peter Maydell
2019-04-15 13:11 ` Mathieu Desnoyers [this message]
2019-04-15 13:30 ` Peter Maydell
2019-04-15 13:37 ` Mathieu Desnoyers
2019-04-16 13:39 ` Mathieu Desnoyers
2019-04-17 10:37 ` Richard Earnshaw (lists)
2019-04-17 14:43 ` Mathieu Desnoyers
2019-04-17 15:30 ` Mathieu Desnoyers
2019-04-18 16:18 ` Richard Earnshaw (lists)
2019-04-11 12:24 ` Florian Weimer
2019-04-15 13:22 ` Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=936773156.261.1555333890988.JavaMail.zimbra@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=carlos@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.maydell@linaro.org \
--cc=richard.earnshaw@arm.com \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox