* [PATCH] arm: ftrace: work with CONFIG_DEBUG_SET_MODULE_RONX
@ 2014-04-02 22:10 Rabin Vincent
2014-04-03 1:04 ` Laura Abbott
2014-04-04 23:55 ` Kees Cook
0 siblings, 2 replies; 4+ messages in thread
From: Rabin Vincent @ 2014-04-02 22:10 UTC (permalink / raw)
To: linux-arm-kernel; +Cc: linux-kernel, Rabin Vincent
Make ftrace work with CONFIG_DEBUG_SET_MODULE_RONX by making module text
writable around the place where ftrace does its work, like it is done on
x86 in the patch which introduced CONFIG_DEBUG_SET_MODULE_RONX,
84e1c6bb38eb ("x86: Add RO/NX protection for loadable kernel modules").
Signed-off-by: Rabin Vincent <rabin@rab.in>
---
arch/arm/kernel/ftrace.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
index 34e5664..70ce654 100644
--- a/arch/arm/kernel/ftrace.c
+++ b/arch/arm/kernel/ftrace.c
@@ -14,6 +14,7 @@
#include <linux/ftrace.h>
#include <linux/uaccess.h>
+#include <linux/module.h>
#include <asm/cacheflush.h>
#include <asm/opcodes.h>
@@ -63,6 +64,18 @@ static unsigned long adjust_address(struct dyn_ftrace *rec, unsigned long addr)
}
#endif
+int ftrace_arch_code_modify_prepare(void)
+{
+ set_all_modules_text_rw();
+ return 0;
+}
+
+int ftrace_arch_code_modify_post_process(void)
+{
+ set_all_modules_text_ro();
+ return 0;
+}
+
static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr)
{
return arm_gen_branch_link(pc, addr);
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arm: ftrace: work with CONFIG_DEBUG_SET_MODULE_RONX
2014-04-02 22:10 [PATCH] arm: ftrace: work with CONFIG_DEBUG_SET_MODULE_RONX Rabin Vincent
@ 2014-04-03 1:04 ` Laura Abbott
2014-04-03 16:26 ` Mitchel Humpherys
2014-04-04 23:55 ` Kees Cook
1 sibling, 1 reply; 4+ messages in thread
From: Laura Abbott @ 2014-04-03 1:04 UTC (permalink / raw)
To: Rabin Vincent, linux-arm-kernel; +Cc: linux-kernel, mitchelh
On 4/2/2014 3:10 PM, Rabin Vincent wrote:
> Make ftrace work with CONFIG_DEBUG_SET_MODULE_RONX by making module text
> writable around the place where ftrace does its work, like it is done on
> x86 in the patch which introduced CONFIG_DEBUG_SET_MODULE_RONX,
> 84e1c6bb38eb ("x86: Add RO/NX protection for loadable kernel modules").
>
> Signed-off-by: Rabin Vincent <rabin@rab.in>
> ---
> arch/arm/kernel/ftrace.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
> index 34e5664..70ce654 100644
> --- a/arch/arm/kernel/ftrace.c
> +++ b/arch/arm/kernel/ftrace.c
> @@ -14,6 +14,7 @@
>
> #include <linux/ftrace.h>
> #include <linux/uaccess.h>
> +#include <linux/module.h>
>
> #include <asm/cacheflush.h>
> #include <asm/opcodes.h>
> @@ -63,6 +64,18 @@ static unsigned long adjust_address(struct dyn_ftrace *rec, unsigned long addr)
> }
> #endif
>
> +int ftrace_arch_code_modify_prepare(void)
> +{
> + set_all_modules_text_rw();
> + return 0;
> +}
> +
> +int ftrace_arch_code_modify_post_process(void)
> +{
> + set_all_modules_text_ro();
> + return 0;
> +}
> +
> static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr)
> {
> return arm_gen_branch_link(pc, addr);
>
I think Mitch tested this on our internal targets. I'll let him reply with his Tested-by
Laura
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm: ftrace: work with CONFIG_DEBUG_SET_MODULE_RONX
2014-04-03 1:04 ` Laura Abbott
@ 2014-04-03 16:26 ` Mitchel Humpherys
0 siblings, 0 replies; 4+ messages in thread
From: Mitchel Humpherys @ 2014-04-03 16:26 UTC (permalink / raw)
To: Laura Abbott; +Cc: Rabin Vincent, linux-arm-kernel, linux-kernel
On Wed, Apr 02 2014 at 06:04:29 PM, Laura Abbott <lauraa@codeaurora.org> wrote:
> I think Mitch tested this on our internal targets. I'll let him reply with his Tested-by
>
> Laura
Indeed:
Tested-by: Mitchel Humpherys <mitchelh@codeaurora.org>
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm: ftrace: work with CONFIG_DEBUG_SET_MODULE_RONX
2014-04-02 22:10 [PATCH] arm: ftrace: work with CONFIG_DEBUG_SET_MODULE_RONX Rabin Vincent
2014-04-03 1:04 ` Laura Abbott
@ 2014-04-04 23:55 ` Kees Cook
1 sibling, 0 replies; 4+ messages in thread
From: Kees Cook @ 2014-04-04 23:55 UTC (permalink / raw)
To: Rabin Vincent; +Cc: linux-arm-kernel@lists.infradead.org, LKML
On Wed, Apr 2, 2014 at 3:10 PM, Rabin Vincent <rabin@rab.in> wrote:
> Make ftrace work with CONFIG_DEBUG_SET_MODULE_RONX by making module text
> writable around the place where ftrace does its work, like it is done on
> x86 in the patch which introduced CONFIG_DEBUG_SET_MODULE_RONX,
> 84e1c6bb38eb ("x86: Add RO/NX protection for loadable kernel modules").
>
> Signed-off-by: Rabin Vincent <rabin@rab.in>
This works for me as well. Thanks!
Tested-by: Kees Cook <keescook@chromium.org>
-Kees
> ---
> arch/arm/kernel/ftrace.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
> index 34e5664..70ce654 100644
> --- a/arch/arm/kernel/ftrace.c
> +++ b/arch/arm/kernel/ftrace.c
> @@ -14,6 +14,7 @@
>
> #include <linux/ftrace.h>
> #include <linux/uaccess.h>
> +#include <linux/module.h>
>
> #include <asm/cacheflush.h>
> #include <asm/opcodes.h>
> @@ -63,6 +64,18 @@ static unsigned long adjust_address(struct dyn_ftrace *rec, unsigned long addr)
> }
> #endif
>
> +int ftrace_arch_code_modify_prepare(void)
> +{
> + set_all_modules_text_rw();
> + return 0;
> +}
> +
> +int ftrace_arch_code_modify_post_process(void)
> +{
> + set_all_modules_text_ro();
> + return 0;
> +}
> +
> static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr)
> {
> return arm_gen_branch_link(pc, addr);
> --
> 1.9.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
Kees Cook
Chrome OS Security
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-04 23:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-02 22:10 [PATCH] arm: ftrace: work with CONFIG_DEBUG_SET_MODULE_RONX Rabin Vincent
2014-04-03 1:04 ` Laura Abbott
2014-04-03 16:26 ` Mitchel Humpherys
2014-04-04 23:55 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox