Re: [PATCH 1/3] Revert "x86/retpoline: Remove .text..__x86.return_thunk section"

From: Josh Poimboeuf
Date: Tue Oct 10 2023 - 16:19:20 EST


On Tue, Oct 10, 2023 at 10:04:29PM +0200, Borislav Petkov wrote:
> On Tue, Oct 10, 2023 at 12:57:21PM -0700, Josh Poimboeuf wrote:
> > Also we could make objtool properly detect the non-relocated jump
> > target.
>
> I was wondering about that... I guess it can compute the JMP target and
> compare it to the address of __x86_return_thunk?

Fine, you twisted my arm ;-)

This seems to do the trick. Lemme write up a proper patch.

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index e308d1ba664e..6cbc9812a36e 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1610,6 +1610,11 @@ static int add_jump_destinations(struct objtool_file *file)
return -1;
}

+ if (jump_dest->sym && jump_dest->sym->return_thunk) {
+ add_return_call(file, insn, true);
+ continue;
+ }
+
/*
* Cross-function jump.
*/