On Mon, Apr 09, 2018 at 07:03:46PM +0900, Prashant Bhole wrote:
> A use-after-free bug was caught by KASAN while running usdt related
> code. (BCC project. bcc/tests/python/test_usdt2.py)
> Allocated by task 870:
> Freed by task 0:
> The buggy address belongs to the object at ffff880384f9b480
> which belongs to the cache task_struct of size 12928
> It occurs because task_struct is freed before perf_event which refers
> to the task and task flags are checked while teardown of the event.
> perf_event_alloc() assigns task_struct to hw.target of perf_event,
> but there is no reference counting for it.
> As a fix we get_task_struct() in perf_event_alloc() at above mentioned
> assignment and put_task_struct() in _free_event().
> Signed-off-by: Prashant Bhole <bhole_prashant...@lab.ntt.co.jp>
Acked-by: Peter Zijlstra (Intel) <pet...@infradead.org>
Ingo, can you make this happen, probably with a Cc-stable as well.