From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/2] arm64: ftrace: don't validate branch via PLT in ftrace_make_nop()
Date: Mon, 5 Jun 2017 18:15:52 +0100 [thread overview]
Message-ID: <20170605171552.GQ21944@arm.com> (raw)
In-Reply-To: <20170530135220.20759-2-ard.biesheuvel@linaro.org>
On Tue, May 30, 2017 at 01:52:19PM +0000, Ard Biesheuvel wrote:
> When turning branch instructions into NOPs, we attempt to validate the
> action by comparing the old value at the call site with the opcode of
> a direct relative branch instruction pointing at the old target.
>
> However, these call sites are statically initialized to call _mcount(),
> and may be redirected via a PLT entry if the module is loaded far away
> from the kernel text, leading to false negatives and spurious errors.
>
> So skip the validation if CONFIG_ARM64_MODULE_PLTS is configured.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> arch/arm64/kernel/ftrace.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
> index 40ad08ac569a..a8db6857cad6 100644
> --- a/arch/arm64/kernel/ftrace.c
> +++ b/arch/arm64/kernel/ftrace.c
> @@ -84,12 +84,15 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
> unsigned long addr)
> {
> unsigned long pc = rec->ip;
> - u32 old, new;
> + u32 old = 0, new;
>
> - old = aarch64_insn_gen_branch_imm(pc, addr, AARCH64_INSN_BRANCH_LINK);
> + if (!IS_ENABLED(CONFIG_ARM64_MODULE_PLTS))
> + old = aarch64_insn_gen_branch_imm(pc, addr,
> + AARCH64_INSN_BRANCH_LINK);
> new = aarch64_insn_gen_nop();
>
> - return ftrace_modify_code(pc, old, new, true);
> + return ftrace_modify_code(pc, old, new,
> + !IS_ENABLED(CONFIG_ARM64_MODULE_PLTS));
Even in the case of PLTs, the instruction is still a branch instruction,
so could we validate the basic opcode fields rather than disable the check
altogether?
Will
next prev parent reply other threads:[~2017-06-05 17:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-30 13:52 [PATCH v2 0/2] arm64: ftrace: fix interop issues with module PLTs Ard Biesheuvel
2017-05-30 13:52 ` [PATCH v2 1/2] arm64: ftrace: don't validate branch via PLT in ftrace_make_nop() Ard Biesheuvel
2017-06-05 17:15 ` Will Deacon [this message]
2017-06-05 17:26 ` Ard Biesheuvel
2017-05-30 13:52 ` [PATCH v2 2/2] arm64: ftrace: add support for far branches to dynamic ftrace Ard Biesheuvel
2017-06-05 17:15 ` Will Deacon
2017-06-07 15:46 ` Steven Rostedt
2017-06-07 15:50 ` Ard Biesheuvel
2017-06-07 16:56 ` Will Deacon
2017-06-07 19:02 ` Steven Rostedt
2017-06-08 9:59 ` Will Deacon
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=20170605171552.GQ21944@arm.com \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.