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

> +++ 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?



[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