lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 19 Sep 2023 21:18:04 -0400
From:   Steven Rostedt <rostedt@...dmis.org>
To:     "Masami Hiramatsu (Google)" <mhiramat@...nel.org>
Cc:     linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
        Mark Rutland <mark.rutland@....com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Ajay Kaher <akaher@...are.com>, chinglinyu@...gle.com,
        lkp@...el.com, namit@...are.com, oe-lkp@...ts.linux.dev,
        amakhalov@...are.com, er.ajay.kaher@...il.com,
        srivatsa@...il.mit.edu, tkundu@...are.com, vsirnapalli@...are.com
Subject: Re: [PATCH 1/2 v3] eventfs: Remove eventfs_file and just use
 eventfs_inode

On Tue, 19 Sep 2023 18:41:09 +0900
Masami Hiramatsu (Google) <mhiramat@...nel.org> wrote:

> > > >  	ti = get_tracefs(inode);
> > > >  	if (!(ti->flags & TRACEFS_EVENT_INODE))
> > > > @@ -375,10 +485,18 @@ static int eventfs_release(struct inode *inode, struct file *file)
> > > >  
> > > >  	ei = ti->private;
> > > >  	idx = srcu_read_lock(&eventfs_srcu);
> > > > -	list_for_each_entry_srcu(ef, &ei->e_top_files, list,
> > > > +	list_for_each_entry_srcu(ei_child, &ei->children, list,
> > > >  				 srcu_read_lock_held(&eventfs_srcu)) {
> > > >  		mutex_lock(&eventfs_mutex);
> > > > -		dentry = ef->dentry;
> > > > +		dentry = ei_child->dentry;
> > > > +		mutex_unlock(&eventfs_mutex);    
> > > 
> > > If someone add a directory via eventfs_create_dir() in parallel, is this
> > > local mutex_lock able to protect from that? (usually it may not happen.)  
> > 
> > That would require an event being added and created at the same time. Not
> > sure that is possible.
> > 
> > We could try it?  
> 
> Not sure, but both eventfs_release() and eventfs_create_dir() will be
> called from dynamic events, right? But the dynamic events will protect
> the create/delete operation with a mutex, so it should not happen if
> I understand correctly.
> But if the eventfs requires such external exclusion for the operation,
> it should be commented.

Hmm, actually looking at this, it's worse than what you stated. This is
called when a directory is closed. So if you had:

	open(dir);

	// look at all the content of this dir to create dentries

	// another task creates a new entry and looks at it too.

	close(dir);

Now we iterate over all the dentries of the dir and dput it.

I think this will cause the ref counts to get out of sync. I'll have to try
to create this scenario and see what happens.



> 
> >   
> > >   
> > > > +		if (dentry)
> > > > +			dput(dentry);
> > > > +	}
> > > > +
> > > > +	for (i = 0; i < ei->nr_entries; i++) {
> > > > +		mutex_lock(&eventfs_mutex);
> > > > +		dentry = ei->d_children[i];
> > > >  		mutex_unlock(&eventfs_mutex);    
> > > 
> > > Ditto. Maybe I'm misunderstanding how eventfs_mutex is used.  
> > 
> > I'll have to go back and look at this part on why I had this. I think it
> > was to make sure ei->d_children existed. But it may also need a test too. I
> > don't remember. :-/  

I believe this is to keep this and create_file_dentry() in sync.

But I need to look deeper. I'm still very new with understanding how all
this file system code works :-p

-- Steve

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ