Re: [PATCH 04/16] perf, mmap: Factor out perf_get_fd()

From: Peter Zijlstra
Date: Fri Apr 25 2014 - 10:52:16 EST


On Fri, Apr 25, 2014 at 04:43:01PM +0200, Peter Zijlstra wrote:
> On Fri, Apr 25, 2014 at 03:54:13PM +0200, Robert Richter wrote:
> > I guess its this patch from Al you referring to:
> >
> > ea635c6 Fix racy use of anon_inode_getfd() in perf_event.c
> >
> > I think we do not introduce it back due to:
> >
> > a6fa941 perf_event: Switch to internal refcount, fix race with close()
> >
> > which removes the user of event_file.
>
> linux-2.6# git show a6fa941
> error: short SHA1 a6fa941 is ambiguous.
> error: short SHA1 a6fa941 is ambiguous.
> fatal: ambiguous argument 'a6fa941': unknown revision or path not in the working tree.
>
> Which is I think why Linus makes us use 12 chars instead of the git
> default of 8.
>
> Of course its also entirely useless of git to not list the full IDs for
> those it did find to be ambiguous.

ok, so its a6fa941d94b4.

But no, I don't think that helps, its still true that the moment you get
a fd another thread can immediately close(). That would drop the last
ref and free it, meanwhile perf_event_open() is happily poking at it.

Now I think you could cure this by adding an extra ref before calling
your perf_get_fd() and dropping that extra ref at the end, where we used
to have fd_install().
--
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/