Re: [PATCH] ftrace: Avoid double-free of dyn_ftrace

From: Steven Rostedt
Date: Tue Mar 24 2009 - 22:35:43 EST


On Wed, Mar 25, 2009 at 10:25:47AM +0800, Zhaolei wrote:
> >> >
> >> > I'm wondering, did you trigger this in practice (if yes, how?),
> >> > or have you found it via code review?
> >> Hello, Ingo
> >>
> >> It is found via code review.
> >
> > Hmm, could you explain this more. I'm thinking that this scenario should
> > not happen, and if it does, it should probably be a bug.
> >
> > Because when we call ftrace_free_rec we change the rec->ip to point to the
> > next record in the chain. Something is very wrong if rec->ip >= s &&
> > rec->ip < e and the record is already free.
> Hello, Steven
>
> Thanks for your comment.
> I got your meaning, and I agree that if rec->ip >= s && rec->ip < e,
> this record is not freed.
> But IMHO, "if rec->ip >= s && rec->ip < e" is used to select records in the module,
> and function of ignore "freed record" is only its side-effect.
> So, add a special judgement to avoid "freed record" is not a bad idea.
> And I also agree your suggestion of add a WARN_ON, because this should not happened.

Hi Zhaolei,

Great! Feel free to send another patch ;-)

Note, use FTRACE_WARN_ON() macro. This way it shuts down ftrace if it is hit and
helps to avoid further damage later.

-- Steve

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/