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

From: Andy Lutomirski
Date: Thu Nov 29 2018 - 12:53:03 EST



> On Nov 29, 2018, at 9:45 AM, Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:
>
>> On Thu, Nov 29, 2018 at 09:41:33AM -0800, Andy Lutomirski wrote:
>>
>>> On Nov 29, 2018, at 9:21 AM, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>>>
>>> On Thu, 29 Nov 2018 12:20:00 -0500
>>> Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>>>
>>>
>>>> r8 = return address
>>>> r9 = function to call
>>>>
>>>
>>> Bad example, r8 and r9 are args, but r10 and r11 are available.
>>>
>>> -- Steve
>>>
>>>> push r8
>>>> jmp *r9
>>>>
>>>> Then have the regs->ip point to that trampoline.
>>
>> Cute. Thatâll need ORC annotations and some kind of retpoline to replace the indirect jump, though.
>
> I'm going with this idea, but the BP is so rare that I really don't see
> why a retpoline would be needed.
>

Without the retpoline in place, you are vulnerable to security researchers causing you a personal denial of service by finding a way to cause the BP to get hit, mistraining the branch predictor, and writing a paper about it :)