Re: [PATCH 2/2] x86/retpoline,kprobes: Avoid treating rethunk as an indirect jump

From: Peter Zijlstra
Date: Wed Jul 05 2023 - 05:04:58 EST


On Wed, Jul 05, 2023 at 10:15:47AM +0200, Petr Pavlu wrote:

> ---
> arch/x86/kernel/vmlinux.lds.S | 2 --
> arch/x86/lib/retpoline.S | 4 ++++
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
> index a4cd04c458df..dd5b0a68cf84 100644
> --- a/arch/x86/kernel/vmlinux.lds.S
> +++ b/arch/x86/kernel/vmlinux.lds.S
> @@ -133,9 +133,7 @@ SECTIONS
> KPROBES_TEXT
> SOFTIRQENTRY_TEXT
> #ifdef CONFIG_RETPOLINE
> - __indirect_thunk_start = .;
> *(.text..__x86.*)
> - __indirect_thunk_end = .;
> #endif

Arguably you could do:

__indirect_thunk_start = .;
*(.text..__x86.indirect_thunk)
__indirect_thunk_end = .;
*(.text..__x86.return_think)

Or somesuch, seems simpler to me.