Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-14 Thread Masami Hiramatsu
On Mon, 13 Jul 2020 08:05:49 +0300 Jarkko Sakkinen wrote: > On Fri, Jul 10, 2020 at 12:49:10PM +0200, Peter Zijlstra wrote: > > On Fri, Jul 10, 2020 at 01:36:38PM +0300, Jarkko Sakkinen wrote: > > > Just so that I know (and learn), what did exactly disable optprobes? > > > > So regular, old-skoo

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-14 Thread Masami Hiramatsu
On Mon, 13 Jul 2020 08:49:55 +0300 Jarkko Sakkinen wrote: > On Fri, Jul 10, 2020 at 01:32:38PM +0200, Peter Zijlstra wrote: > > On Fri, Jul 10, 2020 at 07:32:57PM +0900, Masami Hiramatsu wrote: > > > > - page = module_alloc(PAGE_SIZE); > > > > + page = vmalloc(PAGE_SIZE); > > > > > >

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-13 Thread Peter Zijlstra
On Mon, Jul 13, 2020 at 08:05:49AM +0300, Jarkko Sakkinen wrote: > On Fri, Jul 10, 2020 at 12:49:10PM +0200, Peter Zijlstra wrote: > > On Fri, Jul 10, 2020 at 01:36:38PM +0300, Jarkko Sakkinen wrote: > > > Just so that I know (and learn), what did exactly disable optprobes? > > > > So regular, old

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-12 Thread Jarkko Sakkinen
On Fri, Jul 10, 2020 at 08:51:56AM -0700, Kees Cook wrote: > On Fri, Jul 10, 2020 at 07:32:57PM +0900, Masami Hiramatsu wrote: > > On Fri, 10 Jul 2020 02:45:19 +0300 > > Jarkko Sakkinen wrote: > > > +#ifdef CONFIG_MODULES > > > /* Lock modules while optimizing kprobes */ > > > mutex_lock(&modu

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-12 Thread Jarkko Sakkinen
On Fri, Jul 10, 2020 at 09:22:43AM -0400, Steven Rostedt wrote: > On Fri, 10 Jul 2020 22:18:02 +0900 > Masami Hiramatsu wrote: > > > > > Agreed. As far as I know, ftrace and bpf also depends on module_alloc(), > > so text_alloc() will help them too. > > > > Yes please. > > arch/x86/kernel/ftr

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-12 Thread Jarkko Sakkinen
On Fri, Jul 10, 2020 at 03:04:29PM +0200, Christoph Hellwig wrote: > On Fri, Jul 10, 2020 at 01:32:38PM +0200, Peter Zijlstra wrote: > > On Fri, Jul 10, 2020 at 07:32:57PM +0900, Masami Hiramatsu wrote: > > > > - page = module_alloc(PAGE_SIZE); > > > > + page = vmalloc(PAGE_SIZE); > > >

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-12 Thread Jarkko Sakkinen
On Fri, Jul 10, 2020 at 01:32:38PM +0200, Peter Zijlstra wrote: > On Fri, Jul 10, 2020 at 07:32:57PM +0900, Masami Hiramatsu wrote: > > > - page = module_alloc(PAGE_SIZE); > > > + page = vmalloc(PAGE_SIZE); > > > > No, you can not use vmalloc here. The reason why we use module_alloc() > > is to al

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-12 Thread Jarkko Sakkinen
On Fri, Jul 10, 2020 at 07:32:57PM +0900, Masami Hiramatsu wrote: > Hi Jarkko, > > On Fri, 10 Jul 2020 02:45:19 +0300 > Jarkko Sakkinen wrote: > > > Remove MODULES dependency and migrate from module_alloc to vmalloc(). > > According to Andi, the history with this dependency is that kprobes > > o

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-12 Thread Jarkko Sakkinen
On Fri, Jul 10, 2020 at 12:49:10PM +0200, Peter Zijlstra wrote: > On Fri, Jul 10, 2020 at 01:36:38PM +0300, Jarkko Sakkinen wrote: > > Just so that I know (and learn), what did exactly disable optprobes? > > So regular, old-skool style kprobe is: > > - copy original instruction out > - replac

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-10 Thread Kees Cook
On Fri, Jul 10, 2020 at 07:32:57PM +0900, Masami Hiramatsu wrote: > On Fri, 10 Jul 2020 02:45:19 +0300 > Jarkko Sakkinen wrote: > > +#ifdef CONFIG_MODULES > > /* Lock modules while optimizing kprobes */ > > mutex_lock(&module_mutex); > > +#endif > > Hmm, can you reduce these "#ifdef CONFI

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-10 Thread Steven Rostedt
On Fri, 10 Jul 2020 22:18:02 +0900 Masami Hiramatsu wrote: > > Agreed. As far as I know, ftrace and bpf also depends on module_alloc(), > so text_alloc() will help them too. > Yes please. arch/x86/kernel/ftrace.c: #ifdef CONFIG_MODULES #include /* Module allocation simplifies allocating mem

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-10 Thread Masami Hiramatsu
On Fri, 10 Jul 2020 13:32:38 +0200 Peter Zijlstra wrote: > On Fri, Jul 10, 2020 at 07:32:57PM +0900, Masami Hiramatsu wrote: > > > - page = module_alloc(PAGE_SIZE); > > > + page = vmalloc(PAGE_SIZE); > > > > No, you can not use vmalloc here. The reason why we use module_alloc() > > is to allocat

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-10 Thread Christoph Hellwig
On Fri, Jul 10, 2020 at 01:32:38PM +0200, Peter Zijlstra wrote: > On Fri, Jul 10, 2020 at 07:32:57PM +0900, Masami Hiramatsu wrote: > > > - page = module_alloc(PAGE_SIZE); > > > + page = vmalloc(PAGE_SIZE); > > > > No, you can not use vmalloc here. The reason why we use module_alloc() > > is to al

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-10 Thread Peter Zijlstra
On Fri, Jul 10, 2020 at 07:32:57PM +0900, Masami Hiramatsu wrote: > > - page = module_alloc(PAGE_SIZE); > > + page = vmalloc(PAGE_SIZE); > > No, you can not use vmalloc here. The reason why we use module_alloc() > is to allocate the executable memory for trampoline code. > So, you need to use

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-10 Thread Peter Zijlstra
On Fri, Jul 10, 2020 at 01:36:38PM +0300, Jarkko Sakkinen wrote: > Just so that I know (and learn), what did exactly disable optprobes? So regular, old-skool style kprobe is: - copy original instruction out - replace instruction with breakpoint (int3 on x86) - have exception handler return

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-10 Thread Jarkko Sakkinen
On Fri, Jul 10, 2020 at 11:03:44AM +0200, Peter Zijlstra wrote: > On Fri, Jul 10, 2020 at 02:45:19AM +0300, Jarkko Sakkinen wrote: > > Remove MODULES dependency and migrate from module_alloc to vmalloc(). > > According to Andi, the history with this dependency is that kprobes > > originally require

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-10 Thread Masami Hiramatsu
Hi Jarkko, On Fri, 10 Jul 2020 02:45:19 +0300 Jarkko Sakkinen wrote: > Remove MODULES dependency and migrate from module_alloc to vmalloc(). > According to Andi, the history with this dependency is that kprobes > originally required custom LKM's, which does not hold today anymore. > > Right now

Re: [PATCH RFC] kprobes: Remove MODULES dependency

2020-07-10 Thread Peter Zijlstra
On Fri, Jul 10, 2020 at 02:45:19AM +0300, Jarkko Sakkinen wrote: > Remove MODULES dependency and migrate from module_alloc to vmalloc(). > According to Andi, the history with this dependency is that kprobes > originally required custom LKM's, which does not hold today anymore. > > Right now one ha

[PATCH RFC] kprobes: Remove MODULES dependency

2020-07-09 Thread Jarkko Sakkinen
Remove MODULES dependency and migrate from module_alloc to vmalloc(). According to Andi, the history with this dependency is that kprobes originally required custom LKM's, which does not hold today anymore. Right now one has to compile LKM support only to enable kprobes. With this change applied,