This is a note to let you know that I've just added the patch titled Revert "x86/ftrace: Use alternative RET encoding" to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: revert-x86-ftrace-use-alternative-ret-encoding.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Fri Sep 16 11:33:35 AM CEST 2022 From: Ovidiu Panait <ovidiu.panait@xxxxxxxxxxxxx> Date: Wed, 14 Sep 2022 14:52:36 +0300 Subject: Revert "x86/ftrace: Use alternative RET encoding" To: stable@xxxxxxxxxxxxxxx Cc: paul.gortmaker@xxxxxxxxxxxxx, gregkh@xxxxxxxxxxxxxxxxxxx, peterz@xxxxxxxxxxxxx, bp@xxxxxxx, jpoimboe@xxxxxxxxxx, cascardo@xxxxxxxxxxxxx, Ovidiu Panait <ovidiu.panait@xxxxxxxxxxxxx> Message-ID: <20220914115238.882630-1-ovidiu.panait@xxxxxxxxxxxxx> From: Thadeu Lima de Souza Cascardo <cascardo@xxxxxxxxxxxxx> This reverts commit 00b136bb6254e0abf6aaafe62c4da5f6c4fea4cb. This temporarily reverts the backport of upstream commit 1f001e9da6bbf482311e45e48f53c2bd2179e59c. It was not correct to copy the ftrace stub as it would contain a relative jump to the return thunk which would not apply to the context where it was being copied to, leading to ftrace support to be broken. Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@xxxxxxxxxxxxx> Signed-off-by: Ovidiu Panait <ovidiu.panait@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- arch/x86/kernel/ftrace.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c @@ -309,7 +309,7 @@ union ftrace_op_code_union { } __attribute__((packed)); }; -#define RET_SIZE (IS_ENABLED(CONFIG_RETPOLINE) ? 5 : 1 + IS_ENABLED(CONFIG_SLS)) +#define RET_SIZE 1 + IS_ENABLED(CONFIG_SLS) static unsigned long create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size) @@ -368,10 +368,7 @@ create_trampoline(struct ftrace_ops *ops /* The trampoline ends with ret(q) */ retq = (unsigned long)ftrace_stub; - if (cpu_feature_enabled(X86_FEATURE_RETHUNK)) - memcpy(ip, text_gen_insn(JMP32_INSN_OPCODE, ip, &__x86_return_thunk), JMP32_INSN_SIZE); - else - ret = copy_from_kernel_nofault(ip, (void *)retq, RET_SIZE); + ret = copy_from_kernel_nofault(ip, (void *)retq, RET_SIZE); if (WARN_ON(ret < 0)) goto fail; Patches currently in stable-queue which might be from ovidiu.panait@xxxxxxxxxxxxx are queue-5.10/x86-ftrace-use-alternative-ret-encoding.patch queue-5.10/revert-x86-ftrace-use-alternative-ret-encoding.patch queue-5.10/x86-ibt-ftrace-make-function-graph-play-nice.patch