Re: Re: [RFC PATCH V2] tracing: Check f_dentry before accessingevent_file/call in inode->i_private

From: Oleg Nesterov
Date: Fri Jul 19 2013 - 09:38:52 EST


On 07/19, Masami Hiramatsu wrote:
>
> (2013/07/18 23:51), Oleg Nesterov wrote:
> > It removes trace_array_get/put from tracing_open_generic_file() and
> > tracing_release_generic_file(). This assumes that "call->flags++" is
> > enough, but it is not.
>
> No, it replaces trace_array_get/put with ftrace_event_file_get/put
> which calls trace_array_get/put inside.

Ah, I didn't notice your patch adds "file->tr->ref++" into
ftrace_event_file_get...

So I was wrong in any case, thanks for correcting me.

But,

> (Just one point, previous ftrace_event_file_get has a racy point
> when it does tr->ref++, it should be fixed.)

Not sure what do you mean, but unless I missed something again this
"tr->ref++" above still looks racy. instance_delete() checks tr->ref
first, then it takes event_mutex and removes/kfrees event_files.

But this doesn't really matter even if I am right, surely this can
be fixed. My only point, imho this is more complex than necessary.

In particular,

> > IOW, I believe that either .open() should do trace_array_get(), or
> > __trace_remove_event_dirs() needs another for-each-file loop which
> > checks file->call->flags & TRACE_EVENT_FL_REF_MASK.
>
> Agreed :)

Yes ;) and this makes the ref-counting even more complex, we use
different methods to avoid the races with rmdir and event_remove().

> > The same bugs which Steven's 1/4 tries to solve ;)
>
> OK, let me confirm that, would you mean we still need 2/4 - 4/4?

Yes, yes.

Oleg.

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