Re: [PATCH] perf: Don't enable the perf_event without in PERF_ATTACH_CONTEXT status

From: Peter Zijlstra
Date: Mon Jul 14 2014 - 08:15:46 EST


On Thu, Jul 03, 2014 at 11:36:38AM +0800, Chen LinX wrote:
> From: "Chen LinX" <linx.z.chen@xxxxxxxxx>
>
> when do cpu hotplug test and run below perf test together, pmu may access freed perf_event
>
> while true;
> do
> perf record -a -g -f sleep 10
> rm perf.*
> done
>
> the scenario is that when cpu offline firstly, the 'perf_cpu_notify' will disable event on the
> pmu and remove it from the context list. after cpu online, the perf app may enable the event
> that without linked in context list again. when cpu offine the second time, the 'perf_cpu_notify'
> can't disable event on the pmu as the event doesn't link to context list. the perf app may free
> this event later(the free procedure try to disable event on the pmu but as the cpu is offline,
> the 'cpu_function_call(event->cpu, __perf_remove_from_context, event)' is failed). then after
> cpu online again, pmu will access freed perf_event and hit panic.

What?

(also, teach your MUA to wrap text at 78 chars)

Attachment: pgp6aM_kxVAPy.pgp
Description: PGP signature