x86/ftrace: Make sure that ftrace trampolines are not RWX
authorThomas Gleixner <tglx@linutronix.de>
Thu, 25 May 2017 08:57:51 +0000 (10:57 +0200)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Sat, 27 May 2017 02:37:02 +0000 (22:37 -0400)
commit6ee98ffeea0bc9e072e419497d78697d8afcdd6d
treed1fdc5c65a3006941edc142b86935d6cffe55ce8
parenta53276e2826010338478ed94310874001a8097fa
x86/ftrace: Make sure that ftrace trampolines are not RWX

ftrace use module_alloc() to allocate trampoline pages. The mapping of
module_alloc() is RWX, which makes sense as the memory is written to right
after allocation. But nothing makes these pages RO after writing to them.

Add proper set_memory_rw/ro() calls to protect the trampolines after
modification.

Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1705251056410.1862@nanos
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
arch/x86/kernel/ftrace.c