Re: [Bug][perf hw-breakpoints] Null pointer exception when usingregister_user_hw_breakpoint with inherit flag

From: Peter Zijlstra
Date: Thu Dec 17 2009 - 12:13:49 EST


On Thu, 2009-12-17 at 22:33 +0530, K.Prasad wrote:
> Hi,
> While testing out two new interfaces (to be sent separately) that
> in-turn uses register_user_hw_breakpoint() and unregister_hw_breakpoint(),
> I noticed the following error.
>
> The bug is seen only when 'inherit' flag of 'perf_event_attr' is set
> (not otherwise) before the call to register_user_hw_breakpoint(),
> and when the user-space process tries to spawn a new thread.
>
> Please find the screen logs taken from an x86 box, running -tip kernel
> commit 7818b3d0fc68f5c2a85fed86d9fa37131c5a3068.
>
> Digging further, the causative line of code appears to be
>
> atomic_long_inc(&parent_event->filp->f_count);
>
> in inherit_event() function, wherein f_count is NULL (and hence the
> error). I haven't analysed further to understand why/if the said
> pointer is/should be NULL.
>
> Thought might bring it to the community's notice for wider
> notice/further investigation.

Ooh, cute, it seems the inherit code assumes we have a file structure
around, which isn't true for events that get created through the kernel
interface.

I think its a simple matter of testing to see if event->filp is set, but
we'd better audit the code for it.

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