Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Steven Rostedt
On Fri, 26 May 2017 15:50:38 +0200 (CEST) Thomas Gleixner wrote: > That's very early boot, right? So interrupts have to be disabled. > > So this wants to be: > >BUG_ON(irqs_disabled() && !early_boot_irqs_disabled); > I was thinking the same thing. I'll add a patch

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Steven Rostedt
On Fri, 26 May 2017 15:50:38 +0200 (CEST) Thomas Gleixner wrote: > That's very early boot, right? So interrupts have to be disabled. > > So this wants to be: > >BUG_ON(irqs_disabled() && !early_boot_irqs_disabled); > I was thinking the same thing. I'll add a patch and retest. Thanks!

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Thomas Gleixner
On Fri, 26 May 2017, Steven Rostedt wrote: > On Thu, 25 May 2017 10:57:51 +0200 (CEST) > Thomas Gleixner wrote: > > > 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 > >

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Thomas Gleixner
On Fri, 26 May 2017, Steven Rostedt wrote: > On Thu, 25 May 2017 10:57:51 +0200 (CEST) > Thomas Gleixner wrote: > > > 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

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Steven Rostedt
On Thu, 25 May 2017 10:57:51 +0200 (CEST) Thomas Gleixner wrote: > 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

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Steven Rostedt
On Thu, 25 May 2017 10:57:51 +0200 (CEST) Thomas Gleixner wrote: > 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. > >

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Michael Ellerman
Heiko Carstens writes: > On Fri, May 26, 2017 at 09:03:13AM +0200, Thomas Gleixner wrote: >> > It seems like it really should. That would put it in a single place >> > and avoid this mistake again in the future. Does module_memfree() have >> > access to the allocation

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Michael Ellerman
Heiko Carstens writes: > On Fri, May 26, 2017 at 09:03:13AM +0200, Thomas Gleixner wrote: >> > It seems like it really should. That would put it in a single place >> > and avoid this mistake again in the future. Does module_memfree() have >> > access to the allocation size, or does that need to

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Thomas Gleixner
On Fri, 26 May 2017, Heiko Carstens wrote: > On Fri, May 26, 2017 at 09:03:13AM +0200, Thomas Gleixner wrote: > > > It seems like it really should. That would put it in a single place > > > and avoid this mistake again in the future. Does module_memfree() have > > > access to the allocation size,

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Thomas Gleixner
On Fri, 26 May 2017, Heiko Carstens wrote: > On Fri, May 26, 2017 at 09:03:13AM +0200, Thomas Gleixner wrote: > > > It seems like it really should. That would put it in a single place > > > and avoid this mistake again in the future. Does module_memfree() have > > > access to the allocation size,

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Masami Hiramatsu
On Thu, 25 May 2017 12:51:21 -0700 Kees Cook wrote: > On Thu, May 25, 2017 at 10:46 AM, Luis R. Rodriguez wrote: > > On Thu, May 25, 2017 at 10:57:51AM +0200, Thomas Gleixner wrote: > >> ftrace use module_alloc() to allocate trampoline pages. The

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Masami Hiramatsu
On Thu, 25 May 2017 12:51:21 -0700 Kees Cook wrote: > On Thu, May 25, 2017 at 10:46 AM, Luis R. Rodriguez wrote: > > On Thu, May 25, 2017 at 10:57:51AM +0200, Thomas Gleixner wrote: > >> ftrace use module_alloc() to allocate trampoline pages. The mapping of > >> module_alloc() is RWX, which

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Heiko Carstens
On Fri, May 26, 2017 at 09:03:13AM +0200, Thomas Gleixner wrote: > > It seems like it really should. That would put it in a single place > > and avoid this mistake again in the future. Does module_memfree() have > > access to the allocation size, or does that need to get plumbed? > > No, it

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Heiko Carstens
On Fri, May 26, 2017 at 09:03:13AM +0200, Thomas Gleixner wrote: > > It seems like it really should. That would put it in a single place > > and avoid this mistake again in the future. Does module_memfree() have > > access to the allocation size, or does that need to get plumbed? > > No, it

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Thomas Gleixner
On Thu, 25 May 2017, Kees Cook wrote: > On Thu, May 25, 2017 at 10:46 AM, Luis R. Rodriguez wrote: > > On Thu, May 25, 2017 at 10:57:51AM +0200, Thomas Gleixner wrote: > >> ftrace use module_alloc() to allocate trampoline pages. The mapping of > >> module_alloc() is RWX, which

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-26 Thread Thomas Gleixner
On Thu, 25 May 2017, Kees Cook wrote: > On Thu, May 25, 2017 at 10:46 AM, Luis R. Rodriguez wrote: > > On Thu, May 25, 2017 at 10:57:51AM +0200, Thomas Gleixner wrote: > >> ftrace use module_alloc() to allocate trampoline pages. The mapping of > >> module_alloc() is RWX, which makes sense as the

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-25 Thread Kees Cook
On Thu, May 25, 2017 at 10:46 AM, Luis R. Rodriguez wrote: > On Thu, May 25, 2017 at 10:57:51AM +0200, Thomas Gleixner wrote: >> 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

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-25 Thread Kees Cook
On Thu, May 25, 2017 at 10:46 AM, Luis R. Rodriguez wrote: > On Thu, May 25, 2017 at 10:57:51AM +0200, Thomas Gleixner wrote: >> 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

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-25 Thread Luis R. Rodriguez
On Thu, May 25, 2017 at 10:57:51AM +0200, Thomas Gleixner wrote: > 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. > >

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-25 Thread Luis R. Rodriguez
On Thu, May 25, 2017 at 10:57:51AM +0200, Thomas Gleixner wrote: > 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. > >

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-25 Thread Steven Rostedt
On Thu, 25 May 2017 10:57:51 +0200 (CEST) Thomas Gleixner wrote: > 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 >

Re: [PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-25 Thread Steven Rostedt
On Thu, 25 May 2017 10:57:51 +0200 (CEST) Thomas Gleixner wrote: > 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. >

[PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-25 Thread Thomas Gleixner
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

[PATCH V2] x86/ftrace: Make sure that ftrace trampolines are not RWX

2017-05-25 Thread Thomas Gleixner
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