Peter Zijlstra ee88d363d1 x86,static_call: Use alternative RET encoding
In addition to teaching static_call about the new way to spell 'RET',
there is an added complication in that static_call() is allowed to
rewrite text before it is known which particular spelling is required.

In order to deal with this; have a static_call specific fixup in the
apply_return() 'alternative' patching routine that will rewrite the
static_call trampoline to match the definite sequence.

This in turn creates the problem of uniquely identifying static call
trampolines. Currently trampolines are 8 bytes, the first 5 being the
jmp.d32/ret sequence and the final 3 a byte sequence that spells out
'SCT'.

This sequence is used in __static_call_validate() to ensure it is
patching a trampoline and not a random other jmp.d32. That is,
false-positives shouldn't be plenty, but aren't a big concern.

OTOH the new __static_call_fixup() must not have false-positives, and
'SCT' decodes to the somewhat weird but semi plausible sequence:

  push %rbx
  rex.XB push %r12

Additionally, there are SLS concerns with immediate jumps. Combined it
seems like a good moment to change the signature to a single 3 byte
trap instruction that is unique to this usage and will not ever get
generated by accident.

As such, change the signature to: '0x0f, 0xb9, 0xcc', which decodes
to:

  ud1 %esp, %ecx

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
2022-06-27 10:33:58 +02:00
..
2022-03-15 10:32:40 +01:00
2021-11-02 22:22:13 -07:00
2022-02-25 09:36:05 +01:00
2022-04-19 17:14:09 -07:00
2022-05-29 10:31:36 -07:00
2022-05-23 17:51:12 -07:00
2022-05-23 17:51:12 -07:00
2022-04-07 08:27:51 -07:00
2021-03-18 15:31:53 +01:00
2022-06-27 10:33:58 +02:00
2022-03-15 10:32:36 +01:00
2021-12-01 00:06:43 +01:00
2022-04-14 14:09:43 +02:00
2021-03-18 15:31:53 +01:00
2022-05-19 19:30:31 +02:00
2022-04-14 14:09:43 +02:00
2022-02-25 09:36:05 +01:00
2021-10-25 23:02:36 -04:00
2022-04-14 14:09:43 +02:00
2022-06-27 10:33:58 +02:00