Re: [PATCH v2 4/4] x86/static_call: Add inline static call implementation for x86-64

From: Andy Lutomirski
Date: Thu Nov 29 2018 - 13:00:55 EST



> On Nov 29, 2018, at 9:50 AM, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
>> On Thu, Nov 29, 2018 at 9:44 AM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>>
>> Well, the current method (as Jiri mentioned) did get the OK from at
>> least Intel (and that was with a lot of arm twisting to do so).
>
> Guys, when the comparison is to:
>
> - create a huge honking security hole by screwing up the stack frame
>
> or
>
> - corrupt random registers because we "know" they aren't in use

For C calls, we do indeed know that. But I guess there could be asm calls.

>
> then it really sounds pretty safe to just say "ok, just make it
> aligned and update the instruction with an atomic cmpxchg or
> something".

And how do we do that? With a gcc plugin and some asm magic?

>
> Of course, another option is to just say "we don't do the inline case,
> then", and only ever do a call to a stub that does a "jmp"
> instruction.

Thatâs not a terrible idea.

>
> Problem solved, at the cost of some I$. Emulating a "jmp" is trivial,
> in ways emulating a "call" is not.
>
>