From: Arun Sharma <asharma@fb.com>
To: Andrew Lutomirski <luto@mit.edu>
Cc: <linux-kernel@vger.kernel.org>, Kumar Sundararajan <kumar@fb.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
john stultz <johnstul@us.ibm.com>
Subject: Re: [PATCH 2/2] Add a thread cpu time implementation to vDSO
Date: Mon, 12 Dec 2011 16:40:34 -0800 [thread overview]
Message-ID: <4EE69F02.2090805@fb.com> (raw)
In-Reply-To: <CAObL_7GPA2RvVQSO9PhDs0X++=_62B83Y-CM1DL1+a9oftJ=YQ@mail.gmail.com>
On 12/12/11 3:01 PM, Andrew Lutomirski wrote:
>> The timing based attacks depend on the granularity of timestamps. I feel
>> what's available here is too coarse grained to be useful. Happy to
>> disable the code at compile time for those cases. Are there
>> CONFIG_HIGH_SECURITY type of options I could use for this purpose?
>
> It allows anyone to detect with very high precision when context
> switches happen on another CPU. This sounds a little dangerous. I
> don't know if a config option is the right choice.
Minor nit: attacker gets to see sum_exec_runtime - sched_clock(), not
sched_clock() directly. It might still be equally damaging (assuming the
attacker can work out sum_exec_runtime by observing the VVAR page).
Either way, I think it's important to get to the bottom of this.
Conversely, we might want to consider enabling things like this only
under CONFIG_I_TRUST_STUFF_RUNNING_ON_MY_MACHINE.
>> Yes - this should be a separate patch. gcc-4.4 likes to get rid of the
>> instruction in __do_thread_cpu_time without the asm volatile (in spite of
>> the memory clobber).
>>
>
> gcc 4.4 caught a genuine bug in your code. You ignored the return
> value (which is an output constraint), so you weren't using any
> outputs and gcc omitted the apparently useless code. The right fix is
> to check the return value. (And to consider adding the missing
> volatile.)
Yes - there are two bugs here.
>
>>
>>
>>>> + if (vp->tsc_unstable) {
>>>> + struct timespec ts;
>>>> + vdso_fallback_gettime(CLOCK_THREAD_CPUTIME_ID,&ts);
>>>> + return timespec_to_ns(&ts);
>>>> + }
>>>
>>>
>>> Yuck -- another flag indicating whether we're using the tsc.
>>
>>
>> I renamed it to thread_cputime_disabled to deal with NR_CPUS> 64.
>>
>
> Still yuck. IMO this should always work.
>
Yes - but boot time VVAR page allocation is going to take me some time
to implement. In the meanwhile I was merely trying to ensure that
compilation doesn't break for unsupported configs and the app doesn't
get SIGILL when running on old 64 bit CPUs.
[..]
> Sorry, I was unclear. gtod_data contains vclock_mode, which will tell
> you whether the tsc is usable. I have a buggy computer (I'm typing
> this email on it) that has a TSC that is only useful per-process. I
> don't think it's worth supporting this particular case, since it's a
> bios bug and needs fixing by the vendor. It's hopefully rare.
Ah yes. Will make this change as well.
-Arun
next prev parent reply other threads:[~2011-12-13 0:40 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-12 19:36 [PATCH 0/2] " Arun Sharma
2011-12-12 19:36 ` [PATCH 1/2] Extend VVAR support to multiple pages Arun Sharma
2011-12-12 19:36 ` [PATCH 2/2] Add a thread cpu time implementation to vDSO Arun Sharma
2011-12-12 20:13 ` Eric Dumazet
2011-12-12 21:19 ` Arun Sharma
2011-12-12 21:27 ` Eric Dumazet
2011-12-12 21:33 ` Andrew Lutomirski
2011-12-12 22:14 ` Arun Sharma
2011-12-13 8:52 ` Peter Zijlstra
2011-12-13 18:15 ` Arun Sharma
2011-12-13 18:53 ` Peter Zijlstra
2011-12-12 20:15 ` Andrew Lutomirski
2011-12-12 22:49 ` Arun Sharma
2011-12-12 23:01 ` Andrew Lutomirski
2011-12-13 0:40 ` Arun Sharma [this message]
2011-12-12 23:09 ` john stultz
2011-12-12 23:20 ` Arun Sharma
2011-12-12 23:32 ` john stultz
2011-12-12 23:41 ` Andrew Lutomirski
2011-12-12 23:52 ` john stultz
2011-12-13 0:26 ` Arun Sharma
2011-12-19 19:51 [PATCH 0/2] Add a thread cpu time implementation to vDSO (v2) Arun Sharma
2011-12-19 19:51 ` [PATCH 2/2] Add a thread cpu time implementation to vDSO Arun Sharma
2011-12-19 19:58 ` Arun Sharma
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=4EE69F02.2090805@fb.com \
--to=asharma@fb.com \
--cc=johnstul@us.ibm.com \
--cc=kumar@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@mit.edu \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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
Powered by JetHome