From: Andrew Lutomirski <luto@mit.edu>
To: Mikael Pettersson <mikpe@it.uu.se>
Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
x86@kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [GIT pull] x86 vdso updates
Date: Sun, 29 May 2011 23:26:03 -0400 [thread overview]
Message-ID: <BANLkTik1c9BvaoTKTdpTi9MRJYBLsNH4vA@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi=zxA3xzc0pR14rqwaOUXUAyF__MQ@mail.gmail.com>
On Sun, May 29, 2011 at 2:44 PM, Andrew Lutomirski <luto@mit.edu> wrote:
> On Sun, May 29, 2011 at 2:06 PM, Mikael Pettersson <mikpe@it.uu.se> wrote:
>> Andrew Lutomirski writes:
>> > On Sun, May 29, 2011 at 12:01 PM, Mikael Pettersson <mikpe@it.uu.se> wrote:
>> > > Andrew Lutomirski writes:
>> > > >
>> > > > All of the vsyscalls have vDSO versions that work like any other code.
>> > >
>> > > Easiest would be if we can simply map int $0xcc with rAX==FOO to syscall or
>> > > int 0x80 with rAX==BAR.
>> >
>> > Yes and no.
>> >
>> > With the code I just posted (and am fixing up now) that will work.
>> > But if we want to replace the entire vsyscall page with three int 0xcc
>> > and 4090 int3 instructions, then we can't look at eax because it won't
>> > contain anything meaningful.
>>
>> I can relatively easily also consider the original application rIP
>> when decoding and translating these instructions.
>>
>> >
>> > --Andy
>> >
>> > >
>> > > We currently don't even know about the vDSO, it's all just user-space code
>> > > to us.
>> > >
>> > > > Alternatively, if the dynamic instrumentation code knew about
>> > > > vsyscalls, it could just not instrument addresses in the vsyscall
>> > > > page.
>> > >
>> > > Not instrumenting code is not an option, unless we can prove that the
>> > > code in question has no relevant side-effects or unexpected control-flow.
>> > > (Where "side-effects" relate both to the integrity of the instrumentation
>> > > engine and the application-specific payload it's attaching to the code.)
>> >
>> > Calls to 0xffffffffff600000, 0xffffffffff600400, and
>> > 0xffffffffff600800 are syscalls, as an (unfortunate) part of the ABI.
>> >
>> > >
>> > > > What existing applications would get broken?
>> > >
>> > > My concern is ThreadSpotter, but any user-space dynamic binary instrumentation
>> > > engine that instruments down to the raw kernel interface (syscall/sysenter/int
>> > > instructions) would have a problem with syscalls that only work at specific
>> > > addresses.
>> >
>> > I'll look.
>> >
>> > >
>> > > Anyway, if I can map that vsyscall to a plain proper syscall, then I'm OK.
>> >
>> > All three vsyscalls can be replaced with real syscalls without side
>> > effects. Would it be possible to teach the instrumentation code to
>> > deal with that?
>>
>> Yes, I just need to know how to identify them and what their equivalents are.
>> E.g., an int3 at <known address> becomes syscall rAX=<some constant>.
>>
>> Sounds like this change will be manageable after all. Thanks.
>
> I'm not entirely sure I like that -- that way if we ever change it
> again we break your stuff again.
>
> Here are two proposals.
>
> 1. Teach your code that call 0xffffffffff600000 means
> gettimeofday(rdi, rsi). That's guaranteed to never change and will
> keep working even if we start to emulate vsyscalls by marking the page
> not present and trapping the instruction fetch fault.
valgrind might be doing this. It does not appear to trace directly
into vsyscalls, or at least it doesn't copy the int 0xcc instruction
out of them.
--Andy
prev parent reply other threads:[~2011-05-30 3:26 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-26 18:50 Thomas Gleixner
2011-05-26 21:26 ` Andy Lutomirski
2011-05-27 6:12 ` Ingo Molnar
2011-05-27 11:36 ` Andrew Lutomirski
2011-05-27 11:59 ` richard -rw- weinberger
2011-05-27 12:10 ` Andrew Lutomirski
2011-05-27 14:59 ` richard -rw- weinberger
2011-05-27 15:05 ` Andrew Lutomirski
2011-05-29 9:51 ` richard -rw- weinberger
2011-05-29 14:57 ` Andrew Lutomirski
2011-05-29 15:10 ` richard -rw- weinberger
2011-05-29 15:28 ` Andrew Lutomirski
2011-05-29 16:40 ` richard -rw- weinberger
2011-05-27 14:54 ` Andrew Lutomirski
2011-05-28 15:35 ` Ingo Molnar
2011-05-29 1:41 ` Andrew Lutomirski
2011-05-29 14:39 ` Mikael Pettersson
2011-05-29 14:59 ` Andrew Lutomirski
2011-05-29 16:01 ` Mikael Pettersson
2011-05-29 16:35 ` Andrew Lutomirski
2011-05-29 18:06 ` Mikael Pettersson
2011-05-29 18:44 ` Andrew Lutomirski
2011-05-30 3:26 ` Andrew Lutomirski [this message]
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=BANLkTik1c9BvaoTKTdpTi9MRJYBLsNH4vA@mail.gmail.com \
--to=luto@mit.edu \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikpe@it.uu.se \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®