Re: NULL ptr deref in perf/filter_match

From: Vegard Nossum
Date: Thu Aug 04 2016 - 11:17:40 EST


On 4 August 2016 at 14:37, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> On Fri, Jul 29, 2016 at 11:41:11PM +0200, Vegard Nossum wrote:
>
>> Digging a bit deeper into this, it seems the event itself is getting
>> created by perf_event_open() and it gets added to the pmu_event_list
>> through:
>>
>> perf_event_open()
>> - perf_event_alloc()
>> - account_event()
>> - account_pmu_sb_event()
>> - attach_sb_event()
>>
[...]
>> So I guess the question is... should the event be attached (= put on
>> the list) before ->ctx gets set? Or should the cgroup code check for a
>> NULL ->ctx?
>
> Does this fix it? Ordering is a bit of a mess, adding the events to the
> list _after_ they've been installed has the risk of missing things I
> think, nor does that result in particularly nice code.
>
> Then again, this isn't pretty either.

Patch seems to fix it here, thanks! Feel free to add:

Tested-by: Vegard Nossum <vegard.nossum@xxxxxxxxxx>


Vegard