public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] ftrace: prevent ftrace modifications while being kprobe'd
@ 2008-06-21 18:17 Abhishek Sagar
  2008-06-23 20:15 ` Ingo Molnar
  0 siblings, 1 reply; 6+ messages in thread
From: Abhishek Sagar @ 2008-06-21 18:17 UTC (permalink / raw)
  To: Steven Rostedt, Ingo Molnar; +Cc: Thomas Gleixner, LKML

Hi Steven/Ingo,

These patches address the problem of kprobe registration interfering with
dynamic ftrace. A kprobe registered on an mcount call-site can modify that
address multiple times during its duration of probing. At the same time,
ftrace may simultaneously modify these locations. This could be fatal
especially if ftrace modifies the call-site during a kprobe registration
on it (between arch_prepare_kprobe and arch_arm_kprobe in __register_kprobe
to be more precise). So as a "fix", I've disabled any updates on the mcount
call-site while it's being kprobe'd.

--
Regards,
Abhishek Sagar

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] ftrace: prevent ftrace modifications while being kprobe'd
  2008-06-21 18:17 [PATCH 0/4] ftrace: prevent ftrace modifications while being kprobe'd Abhishek Sagar
@ 2008-06-23 20:15 ` Ingo Molnar
  2008-06-24  3:29   ` Abhishek Sagar
  0 siblings, 1 reply; 6+ messages in thread
From: Ingo Molnar @ 2008-06-23 20:15 UTC (permalink / raw)
  To: Abhishek Sagar; +Cc: Steven Rostedt, Thomas Gleixner, LKML


* Abhishek Sagar <sagar.abhishek@gmail.com> wrote:

> Hi Steven/Ingo,
> 
> These patches address the problem of kprobe registration interfering 
> with dynamic ftrace. A kprobe registered on an mcount call-site can 
> modify that address multiple times during its duration of probing. At 
> the same time, ftrace may simultaneously modify these locations. This 
> could be fatal especially if ftrace modifies the call-site during a 
> kprobe registration on it (between arch_prepare_kprobe and 
> arch_arm_kprobe in __register_kprobe to be more precise). So as a 
> "fix", I've disabled any updates on the mcount call-site while it's 
> being kprobe'd.

applied to tip/tracing/ftrace, thanks Abhishek.

note that i had to do a number of fixups to themerge, and there was one 
chunk which did not merge cleanly and i left it out for now:

@@ -435,8 +502,12 @@ static void ftrace_replace_code(int enable)
                                continue;

                        /* ignore updates to this record's mcount site */
-                       if (get_kprobe((void *)rec->ip))
+                       if (get_kprobe((void *)rec->ip)) {
+                               freeze_record(rec);
                                continue;
+                       } else {
+                               unfreeze_record(rec);
+                       }

please send a delta patch against tip/tracing/ftrace to get that kprobes 
fix. You can pick up -tip via:

 http://people.redhat.com/mingo/tip.git/README

	Ingo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] ftrace: prevent ftrace modifications while being kprobe'd
  2008-06-23 20:15 ` Ingo Molnar
@ 2008-06-24  3:29   ` Abhishek Sagar
  2008-06-26 12:33     ` Ingo Molnar
  0 siblings, 1 reply; 6+ messages in thread
From: Abhishek Sagar @ 2008-06-24  3:29 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Steven Rostedt, Thomas Gleixner, LKML

Hi Ingo,

On Tue, Jun 24, 2008 at 1:45 AM, Ingo Molnar <mingo@elte.hu> wrote:
> note that i had to do a number of fixups to themerge, and there was one
> chunk which did not merge cleanly and i left it out for now:
>
> @@ -435,8 +502,12 @@ static void ftrace_replace_code(int enable)
>                                continue;
>
>                        /* ignore updates to this record's mcount site */
> -                       if (get_kprobe((void *)rec->ip))
> +                       if (get_kprobe((void *)rec->ip)) {
> +                               freeze_record(rec);
>                                continue;
> +                       } else {
> +                               unfreeze_record(rec);
> +                       }

I wonder why it conflicted during the merge. I notice that patch 4/4
has been applied before
3/4. Can you try reversing the order and see if it works? Else I'll redo them.

--
Thanks,
Abhishek Sagar

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] ftrace: prevent ftrace modifications while being kprobe'd
  2008-06-24  3:29   ` Abhishek Sagar
@ 2008-06-26 12:33     ` Ingo Molnar
  2008-06-26 17:21       ` Abhishek Sagar
  0 siblings, 1 reply; 6+ messages in thread
From: Ingo Molnar @ 2008-06-26 12:33 UTC (permalink / raw)
  To: Abhishek Sagar; +Cc: Steven Rostedt, Thomas Gleixner, LKML


* Abhishek Sagar <sagar.abhishek@gmail.com> wrote:

> Hi Ingo,
> 
> On Tue, Jun 24, 2008 at 1:45 AM, Ingo Molnar <mingo@elte.hu> wrote:
> > note that i had to do a number of fixups to themerge, and there was one
> > chunk which did not merge cleanly and i left it out for now:
> >
> > @@ -435,8 +502,12 @@ static void ftrace_replace_code(int enable)
> >                                continue;
> >
> >                        /* ignore updates to this record's mcount site */
> > -                       if (get_kprobe((void *)rec->ip))
> > +                       if (get_kprobe((void *)rec->ip)) {
> > +                               freeze_record(rec);
> >                                continue;
> > +                       } else {
> > +                               unfreeze_record(rec);
> > +                       }
> 
> I wonder why it conflicted during the merge. I notice that patch 4/4 
> has been applied before 3/4. Can you try reversing the order and see 
> if it works? Else I'll redo them.

best would be a delta patch against tip/master to fix up whatever is 
still missing.

	Ingo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] ftrace: prevent ftrace modifications while being kprobe'd
  2008-06-26 12:33     ` Ingo Molnar
@ 2008-06-26 17:21       ` Abhishek Sagar
  2008-07-03 12:49         ` Ingo Molnar
  0 siblings, 1 reply; 6+ messages in thread
From: Abhishek Sagar @ 2008-06-26 17:21 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Steven Rostedt, Thomas Gleixner, LKML

Ingo Molnar wrote:
> best would be a delta patch against tip/master to fix up whatever is 
> still missing.

Here is the merge fixup for tip/master (and tip/tracing/ftrace).

Signed-off-by: Abhishek Sagar <sagar.abhishek@gmail.com>
---

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 85e8413..0f271c4 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -502,8 +502,12 @@ static void ftrace_replace_code(int enable)
 				continue;
 
 			/* ignore updates to this record's mcount site */
-			if (get_kprobe((void *)rec->ip))
+			if (get_kprobe((void *)rec->ip)) {
+				freeze_record(rec);
 				continue;
+			} else {
+				unfreeze_record(rec);
+			}
 
 			failed = __ftrace_replace_code(rec, old, new, enable);
 			if (failed && (rec->flags & FTRACE_FL_CONVERTED)) {
@@ -740,7 +744,10 @@ static int __ftrace_update_code(void *ignore)
 				ftrace_del_hash(p);
 				INIT_HLIST_NODE(&p->node);
 				hlist_add_head(&p->node, &temp_list);
+				freeze_record(p);
 				continue;
+			} else {
+				unfreeze_record(p);
 			}
 
 			/* convert record (i.e, patch mcount-call with NOP) */

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] ftrace: prevent ftrace modifications while being kprobe'd
  2008-06-26 17:21       ` Abhishek Sagar
@ 2008-07-03 12:49         ` Ingo Molnar
  0 siblings, 0 replies; 6+ messages in thread
From: Ingo Molnar @ 2008-07-03 12:49 UTC (permalink / raw)
  To: Abhishek Sagar; +Cc: Steven Rostedt, Thomas Gleixner, LKML


* Abhishek Sagar <sagar.abhishek@gmail.com> wrote:

> Ingo Molnar wrote:
> > best would be a delta patch against tip/master to fix up whatever is 
> > still missing.
> 
> Here is the merge fixup for tip/master (and tip/tracing/ftrace).
> 
> Signed-off-by: Abhishek Sagar <sagar.abhishek@gmail.com>

applied to tip/tracing/ftrace - thanks Abhishek!

	Ingo

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-07-03 12:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-21 18:17 [PATCH 0/4] ftrace: prevent ftrace modifications while being kprobe'd Abhishek Sagar
2008-06-23 20:15 ` Ingo Molnar
2008-06-24  3:29   ` Abhishek Sagar
2008-06-26 12:33     ` Ingo Molnar
2008-06-26 17:21       ` Abhishek Sagar
2008-07-03 12:49         ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox