From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Jiri Kosina <jikos@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Andrea Arcangeli <aarcange@redhat.com>,
"Woodhouse, David" <dwmw@amazon.co.uk>,
Oleg Nesterov <oleg@redhat.com>,
Tim Chen <tim.c.chen@linux.intel.com>,
linux-kernel@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH v3 2/3] x86/speculation: apply IBPB more strictly to avoid cross-process data leak
Date: Wed, 5 Sep 2018 09:59:13 +0200 [thread overview]
Message-ID: <20180905075913.GO24124@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <alpine.DEB.2.21.1809041804080.3395@nanos.tec.linutronix.de>
On Tue, Sep 04, 2018 at 06:18:55PM +0200, Thomas Gleixner wrote:
> On Tue, 4 Sep 2018, Jiri Kosina wrote:
> > if (tsk && tsk->mm &&
> > tsk->mm->context.ctx_id != last_ctx_id &&
> > - get_dumpable(tsk->mm) != SUID_DUMP_USER)
> > + ___ptrace_may_access(current, tsk, PTRACE_MODE_IBPB))
>
> Uurgh. If X86_FEATURE_USE_IBPB is not enabled, then the whole
> __ptrace_may_access() overhead is just done for nothing.
>
> > indirect_branch_prediction_barrier();
>
> This really wants to be runtime patched:
>
> if (static_cpu_has(X86_FEATURE_USE_IBPB))
> stop_speculation(tsk, last_ctx_id);
>
> and have an inline for that:
>
> static inline void stop_speculation(struct task_struct *tsk, u64 last_ctx_id)
> {
> if (tsk && tsk->mm && tsk->mm->context.ctx_id != last_ctx_id &&
> ___ptrace_may_access(current, tsk, PTRACE_MODE_IBPB))
> indirect_branch_prediction_barrier();
> }
>
> which also makes the whole mess readable.
How about something like:
if (static_cpu_has(X86_FEATURE_USE_IBPB) && need_ibpb(tsk, last_ctx_id))
indirect_branch_predictor_barrier();
where:
static inline bool need_ibpb(struct task_struct *next, u64 last_ctx_id)
{
return next && next->mm && next->mm->context.ctx_id != last_ctx_id &&
__ptrace_may_access(next, PTRACE_MODE_IBPB));
}
I don't much like "stop_speculation" for a name here.
next prev parent reply other threads:[~2018-09-05 7:59 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-31 20:56 [PATCH] x86/speculation: Enable cross-hyperthread spectre v2 STIBP mitigation Jiri Kosina
2018-09-03 8:51 ` Jiri Kosina
2018-09-03 12:45 ` [PATCH v2 0/3] Harden spectrev2 userspace-userspace protection Jiri Kosina
2018-09-04 14:23 ` [PATCH v3 " Jiri Kosina
2018-09-04 14:40 ` [PATCH v3 1/3] ptrace: Provide ___ptrace_may_access() that can be applied on arbitrary tasks Jiri Kosina
2018-09-04 16:13 ` Thomas Gleixner
2018-09-04 16:21 ` Thomas Gleixner
2018-09-04 17:26 ` Tim Chen
2018-09-04 17:35 ` Jiri Kosina
2018-09-04 18:10 ` Schaufler, Casey
2018-09-04 18:48 ` Jiri Kosina
2018-09-04 23:26 ` Tim Chen
2018-09-05 6:22 ` Jiri Kosina
2018-09-05 15:58 ` Andi Kleen
2018-09-05 18:04 ` Andrea Arcangeli
2018-09-05 18:29 ` Jiri Kosina
2018-09-05 18:40 ` Andrea Arcangeli
2018-09-05 18:42 ` Jiri Kosina
2018-09-05 19:03 ` Peter Zijlstra
2018-09-05 19:27 ` Schaufler, Casey
2018-09-05 20:02 ` Jiri Kosina
2018-09-05 18:26 ` Thomas Gleixner
2018-09-05 18:35 ` Jiri Kosina
2018-09-04 23:37 ` Andrea Arcangeli
2018-09-05 1:00 ` Schaufler, Casey
2018-09-05 2:38 ` Andrea Arcangeli
2018-09-05 8:00 ` Peter Zijlstra
2018-09-05 15:37 ` Schaufler, Casey
2018-09-05 7:51 ` Peter Zijlstra
2018-09-04 14:42 ` [PATCH v3 2/3] x86/speculation: apply IBPB more strictly to avoid cross-process data leak Jiri Kosina
2018-09-04 16:18 ` Thomas Gleixner
2018-09-05 7:59 ` Peter Zijlstra [this message]
2018-09-05 8:02 ` Jiri Kosina
2018-09-05 9:40 ` Peter Zijlstra
2018-09-05 7:52 ` Peter Zijlstra
2018-09-05 7:55 ` Jiri Kosina
2018-09-04 14:42 ` [PATCH v3 3/3] x86/speculation: Enable cross-hyperthread spectre v2 STIBP mitigation Jiri Kosina
2018-09-04 14:24 [PATCH v3 2/3] x86/speculation: apply IBPB more strictly to avoid cross-process data leak Jiri Kosina
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=20180905075913.GO24124@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=aarcange@redhat.com \
--cc=dwmw@amazon.co.uk \
--cc=jikos@kernel.org \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=tglx@linutronix.de \
--cc=tim.c.chen@linux.intel.com \
--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
Powered by JetHome