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  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, 14 Feb 2017 17:39:47 -0800
From:   Jaegeuk Kim <jaegeuk@...nel.org>
To:     Chao Yu <yuchao0@...wei.com>
Cc:     linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        linux-f2fs-devel@...ts.sourceforge.net, stable@...r.kernel.org
Subject: Re: [f2fs-dev] [PATCH] f2fs: fix multiple f2fs_add_link() calls
 having same name

On 02/15, Chao Yu wrote:
> On 2017/2/15 2:03, Jaegeuk Kim wrote:
> > VFS uses f2fs_lookup() to decide f2fs_add_link() call during file creation.
> > But, if there is a race condition, f2fs_add_link() can be called multiple
> > times, resulting in multiple dentries with a same name. This patches fixes
> > it by adding __f2fs_find_entry() in f2fs_add_link() path.
> 
> As during ->lookup, i_mutex will be held all the time, so there is no race
> condition in between different file creators?

Hehe, yup.
I dropped this patch.

Thanks,

> 
> Thanks,
> 
> > 
> > Cc: <stable@...r.kernel.org>
> > Signed-off-by: Jaegeuk Kim <jaegeuk@...nel.org>
> > ---
> >  fs/f2fs/dir.c | 14 ++++++++++++--
> >  1 file changed, 12 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
> > index 827c5daef4fc..bc7c48839bec 100644
> > --- a/fs/f2fs/dir.c
> > +++ b/fs/f2fs/dir.c
> > @@ -643,14 +643,24 @@ int __f2fs_add_link(struct inode *dir, const struct qstr *name,
> >  				struct inode *inode, nid_t ino, umode_t mode)
> >  {
> >  	struct fscrypt_name fname;
> > +	struct page *page;
> > +	struct f2fs_dir_entry *de;
> >  	int err;
> >  
> >  	err = fscrypt_setup_filename(dir, name, 0, &fname);
> >  	if (err)
> >  		return err;
> >  
> > -	err = __f2fs_do_add_link(dir, &fname, inode, ino, mode);
> > -
> > +	de = __f2fs_find_entry(dir, &fname, &page);
> > +	if (de) {
> > +		f2fs_dentry_kunmap(dir, page);
> > +		f2fs_put_page(page, 0);
> > +		err = -EEXIST;
> > +	} else if (!IS_ERR(page)) {
> > +		err = __f2fs_do_add_link(dir, &fname, inode, ino, mode);
> > +	} else {
> > +		err = PTR_ERR(page);
> > +	}
> >  	fscrypt_free_filename(&fname);
> >  	return err;
> >  }
> > 

Powered by blists - more mailing lists