Re: [PATCH] fs/vfs: Release allocated dentry on failure in do_last()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 07, 2017 at 01:30:03PM +0800, Matthew Wilcox wrote:
> On Thu, Dec 07, 2017 at 10:46:22AM +0800, 穆阿浩(姜弋) wrote:
> > This issue is found when creating /dev/sdtest with flags (O_CREAT |
> > O_DIRECT). The file still can be retrieved even after system reports
> > failure (-EINVAL) for it. Reporting error on creating the file is
> > correct behaviour because either devtmpfs or tmpfs doesn't support
> > O_DIRECT for regular file. However, it's incorrect that the file is
> > still existing. The cause is the newly allocated dentry and inode
> > aren't released on failure in do_last().
> 
> Previously reported:
> 
> https://www.spinics.net/lists/linux-fsdevel/msg89317.html
> https://www.spinics.net/lists/linux-fsdevel/msg113680.html
> http://lkml.iu.edu/hypermail/linux/kernel/1609.0/04556.html
> 

Thanks, Matthew. I start to realize it's a long-standing issue :)

> > +++ b/fs/namei.c
> > @@ -3382,6 +3382,8 @@ static int do_last(struct nameidata *nd,
> >  	*opened |= FILE_OPENED;
> >  opened:
> >  	error = open_check_o_direct(file);
> > +	if (error && (*opened & FILE_OPENED))
> > +		dput(path.dentry);
> >  	if (!error)
> >  		error = ima_file_check(file, op->acc_mode, *opened);
> >  	if (!error && will_truncate)
> 
> Umm ... I think it's too late.  This will work well enough for in-memory
> filesystems, but if you have a real filesystem, there's no call back to
> the filesystem to remove the directory entry, right?

Yeah, it's late to roll back on real filesystem like ext4. As I replied
to Al Viro in another thread, the doable fix would be pass O_DIRECT down
to struct inode_operations::create() and the specific filesystem rejects
creating inode if O_DIRECT isn't supported there.

Cheers,
Gavin



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux