From: Masami Hiramatsu <mhiramat@kernel.org>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org,
Masami Hiramatsu <mhiramat@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Nick Desaulniers <ndesaulniers@google.com>,
kernel test robot <lkp@intel.com>
Subject: Re: [PATCH] ARM: kretprobes: fix out-of-range literal issue in naked asm routine
Date: Fri, 25 Mar 2022 18:42:19 +0900 [thread overview]
Message-ID: <20220325184219.c42feefea5d8b26897d35a63@kernel.org> (raw)
In-Reply-To: <20220325080302.4018956-1-ardb@kernel.org>
On Fri, 25 Mar 2022 09:03:02 +0100
Ard Biesheuvel <ardb@kernel.org> wrote:
> __kretprobe_trampoline is a naked C function implemented in asm, and the
> first thing it does is take its own address and record it in the frame
> record, so that a backtrace will properly traverse its stackframe.
>
> As it turns out, using 'LDR <reg>, =<symbol>' notation is problematic
> here, as it relies on a literal pool to be emitted sufficiently close to
> the LDR instruction, and since the compiler is not aware of this need,
> this results in assembler errors in some cases.
>
> Since the address taken is guaranteed to be the address of the
> instruction itself, just use ADR instead.
Ah, indeed :)
This looks good to me.
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Masami Hiramatsu <mhiramat@kernel.org>
Thank you very much!
>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: 7e9bf33b8124 ("ARM: kprobes: Make a frame pointer on __kretprobe_trampoline")
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> arch/arm/probes/kprobes/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/probes/kprobes/core.c b/arch/arm/probes/kprobes/core.c
> index 9090c3a74dcc..068639a777c8 100644
> --- a/arch/arm/probes/kprobes/core.c
> +++ b/arch/arm/probes/kprobes/core.c
> @@ -377,7 +377,7 @@ void __naked __kprobes __kretprobe_trampoline(void)
> {
> __asm__ __volatile__ (
> #ifdef CONFIG_FRAME_POINTER
> - "ldr lr, =__kretprobe_trampoline \n\t"
> + "adr lr, . \n\t"
> /* __kretprobe_trampoline makes a framepointer on pt_regs. */
> #ifdef CONFIG_CC_IS_CLANG
> "stmdb sp, {sp, lr, pc} \n\t"
> --
> 2.30.2
>
--
Masami Hiramatsu <mhiramat@kernel.org>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2022-03-25 9:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-25 8:03 [PATCH] ARM: kretprobes: fix out-of-range literal issue in naked asm routine Ard Biesheuvel
2022-03-25 9:42 ` Masami Hiramatsu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220325184219.c42feefea5d8b26897d35a63@kernel.org \
--to=mhiramat@kernel.org \
--cc=ardb@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=lkp@intel.com \
--cc=ndesaulniers@google.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).