Re: [PATCH 2/2] tracing/uprobes: disallow unregister trace_uprobewhen trace_uprobe is in use

From: Oleg Nesterov
Date: Tue Jun 25 2013 - 13:28:36 EST


On 06/25, zhangwei(Jovi) wrote:
>
> We cannot unregister trace_uprobe when trace_uprobe is in use,
> otherwise resource will leak.
>
> Just return -EBUSY if user want to unregister a trace_uprobe
> which in use.

Hmm. Afaics, this is not that simple. This patch copies the similar
logic from trace_kprobe.c. I'll recheck later but so far I strongly
believe that code is wrong.

So please forget about trace_uprobe.c for the moment. Let's look at
release_all_trace_probes().

It checks trace_probe_is_enabled(), but how can we trust this check?
We can race with enable_trace_probe() which is going to set
TP_FLAG_TRACE/TP_FLAG_PROFILE.

And no, we can't change enable_trace_probe() to take probe_lock,
this can ABBA with unregister_trace_probe() called under this lock
because of trace_remove_event_call() which takes event_mutex.

At the same time, the fact that trace_remove_event_call() takes
event_mutex can probably help, because __trace_remove_event_call()
should do TRACE_REG_UNREGISTER and this should serialize us with
TRACE_REG_REGISTER.

But TRACE_REG_PERF_REGISTER is different, and does not look safe.
In fact I suspect there are more serious problems, but I need to
recheck.

Oleg.

--
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/