Re: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-28 Thread Masami Hiramatsu
On Fri, 28 Aug 2020 13:11:15 + "eddy...@trendmicro.com" wrote: > > -Original Message > Hi, I found a NULL pointer dereference here, where > current->kretprobe_instances.first == NULL in these two scenario: > > 1) In task "rs:main Q:Reg" > # insmod samples/kprobes/kretprobe_example.k

Re: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-28 Thread Masami Hiramatsu
On Fri, 28 Aug 2020 16:19:17 +0200 pet...@infradead.org wrote: > On Fri, Aug 28, 2020 at 02:11:18PM +, eddy...@trendmicro.com wrote: > > > From: Masami Hiramatsu > > > > > > OK, schedule function will be the key. I guess the senario is.. > > > > > > 1) kretporbe replace the return address wit

Re: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-28 Thread Masami Hiramatsu
On Fri, 28 Aug 2020 15:58:24 +0200 pet...@infradead.org wrote: > On Fri, Aug 28, 2020 at 10:51:13PM +0900, Masami Hiramatsu wrote: > > > OK, schedule function will be the key. I guess the senario is.. > > > > 1) kretporbe replace the return address with kretprobe_trampoline on > > task1's kern

Re: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-28 Thread peterz
On Fri, Aug 28, 2020 at 02:11:18PM +, eddy...@trendmicro.com wrote: > > From: Masami Hiramatsu > > > > OK, schedule function will be the key. I guess the senario is.. > > > > 1) kretporbe replace the return address with kretprobe_trampoline on > > task1's kernel stack > > 2) the task1 forks t

RE: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-28 Thread eddy...@trendmicro.com
> From: Masami Hiramatsu > > OK, schedule function will be the key. I guess the senario is.. > > 1) kretporbe replace the return address with kretprobe_trampoline on task1's > kernel stack > 2) the task1 forks task2 before returning to the kretprobe_trampoline > 3) while copying the process with

Re: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-28 Thread peterz
On Fri, Aug 28, 2020 at 10:51:13PM +0900, Masami Hiramatsu wrote: > OK, schedule function will be the key. I guess the senario is.. > > 1) kretporbe replace the return address with kretprobe_trampoline on task1's > kernel stack > 2) the task1 forks task2 before returning to the kretprobe_trampo

Re: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-28 Thread Masami Hiramatsu
...@kernel.org; > > da...@davemloft.net; rost...@goodmis.org; > > naveen.n@linux.ibm.com; anil.s.keshavamur...@intel.com; > > linux-a...@vger.kernel.org; came...@moodycamel.com; > > o...@redhat.com; w...@kernel.org; paul...@kernel.org; pet...@infradead.org > > Subjec

Re: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-28 Thread peterz
.org; > > da...@davemloft.net; rost...@goodmis.org; > > naveen.n@linux.ibm.com; anil.s.keshavamur...@intel.com; > > linux-a...@vger.kernel.org; came...@moodycamel.com; > > o...@redhat.com; w...@kernel.org; paul...@kernel.org; pet...@infradead.org > &

RE: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-28 Thread eddy...@trendmicro.com
shavamur...@intel.com; > linux-a...@vger.kernel.org; came...@moodycamel.com; > o...@redhat.com; w...@kernel.org; paul...@kernel.org; pet...@infradead.org > Subject: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash > > @@ -1935,71 +1932,45 @@ unsi

Re: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-28 Thread Masami Hiramatsu
On Fri, 28 Aug 2020 03:00:59 +0900 Masami Hiramatsu wrote: > On Thu, 27 Aug 2020 18:12:40 +0200 > Peter Zijlstra wrote: > > > +static void invalidate_rp_inst(struct task_struct *t, struct kretprobe *rp) > > +{ > > + struct invl_rp_ipi iri = { > > + .task = t, > > + .rp = r

Re: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-28 Thread peterz
On Fri, Aug 28, 2020 at 03:00:59AM +0900, Masami Hiramatsu wrote: > On Thu, 27 Aug 2020 18:12:40 +0200 > Peter Zijlstra wrote: > > > +static void invalidate_rp_inst(struct task_struct *t, struct kretprobe *rp) > > +{ > > + struct invl_rp_ipi iri = { > > + .task = t, > > + .r

Re: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-27 Thread Masami Hiramatsu
On Thu, 27 Aug 2020 18:12:40 +0200 Peter Zijlstra wrote: > @@ -1313,25 +1261,28 @@ void kprobe_busy_end(void) > void kprobe_flush_task(struct task_struct *tk) > { > struct kretprobe_instance *ri; > - struct hlist_head *head, empty_rp; > + struct hlist_head empty_rp; > + struct

Re: [RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-27 Thread Masami Hiramatsu
On Thu, 27 Aug 2020 18:12:40 +0200 Peter Zijlstra wrote: > +static void invalidate_rp_inst(struct task_struct *t, struct kretprobe *rp) > +{ > + struct invl_rp_ipi iri = { > + .task = t, > + .rp = rp, > + .done = false > + }; > + > + for (;;) { > +

[RFC][PATCH 3/7] kprobes: Remove kretprobe hash

2020-08-27 Thread Peter Zijlstra
The kretprobe hash is mostly superfluous, replace it with a per-task variable. This gets rid of the task hash and it's related locking. The whole invalidate_rp_inst() is tedious and could go away once we drop rp specific ri size. Signed-off-by: Peter Zijlstra (Intel) --- include/linux/kprobes.