[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YXlOd1lyKZKAcJfA@hirez.programming.kicks-ass.net>
Date: Wed, 27 Oct 2021 15:04:55 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Ard Biesheuvel <ardb@...nel.org>
Cc: Mark Rutland <mark.rutland@....com>,
Sami Tolvanen <samitolvanen@...gle.com>,
X86 ML <x86@...nel.org>, Kees Cook <keescook@...omium.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Sedat Dilek <sedat.dilek@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
linux-hardening@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
llvm@...ts.linux.dev
Subject: Re: [PATCH v5 00/15] x86: Add support for Clang CFI
On Wed, Oct 27, 2021 at 02:48:52PM +0200, Peter Zijlstra wrote:
> On Wed, Oct 27, 2021 at 02:22:27PM +0200, Ard Biesheuvel wrote:
> > On Wed, 27 Oct 2021 at 14:05, Mark Rutland <mark.rutland@....com> wrote:
>
> > > > Should not this jump-table thingy get converted to an actual function
> > > > address somewhere around arch_static_call_transform() ? This also seems
> > > > relevant for arm64 (which already has CLANG_CFI supported) given:
> > > >
> > > > https://lkml.kernel.org/r/20211025122102.46089-3-frederic@kernel.org
> > >
> > > Ugh, yeah, we'll need to do the function_nocfi() dance somewhere...
> > >
> >
> > Sadly, that only works on symbol names, so we cannot use it to strip
> > CFI-ness from void *func arguments passed into the static call API,
> > unfortunately.
>
> Right, and while mostly static_call_update() is used, whcih is a macro
> and could possibly be used to wrap this, we very much rely on
> __static_call_update() also working without that wrapper and then we're
> up a creek without no paddles.
Specifically, we support code like:
struct foo {
void (*func1)(args1);
void (*func2)(args2);
}
struct foo global_foo;
...
DEFINE_STATIC_CALL_NULL(func1, *global_foo.func1);
...
__init foo_init()
{
// whatever code that fills out foo
static_call_update(func1, global_foo.func1);
}
...
hot_function()
{
...
static_cal(func1)(args1);
...
}
cold_function()
{
...
global_foo->func1(args1);
...
}
And there is no way I can see this working sanely with CFI as presented.
Even though the above uses static_call_update(), we can't no longer use
function_nocfi() on the @func argument, because it's not a symbol, it's
already a function pointer.
Nor can we fill global_foo.func1 with function_nocfi() because then
cold_function() goes sideways.
Powered by blists - more mailing lists