Re: [PATCH] vfs: fix bug when opening a file with O_DIRECT on a file system that does not support it will leave an empty file

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

 



On Tue, Jan 04, 2022 at 09:53:58AM +0800, Qinghua Jin wrote:
> Colin Ian King reported the following
> 
> 1. create a minix file system and mount it
> 2. open a file on the file system with O_RDWR | O_CREAT | O_TRUNC | O_DIRECT
> 3. open fails with -EINVAL but leaves an empty file behind.  All other open() failures don't leave the
> failed open files behind.
> 
> The reason is because when checking the O_DIRECT in do_dentry_open, the inode has created, and later err
> processing can't remove the inode:
> 
>         /* NB: we're sure to have correct a_ops only after f_op->open */
>         if (f->f_flags & O_DIRECT) {
>                 if (!f->f_mapping->a_ops || !f->f_mapping->a_ops->direct_IO)
>                         return -EINVAL;
>         }
> 
> The patch will check the O_DIRECT before creating the inode in lookup_open function.

NAK.  You are looking at ->a_ops of the parent directory.  Which might have nothing
whatsoever to do with that of a regular file created in it.

IOW, you've removed the check on the file we are opening and replaced it with
random check that just happens to yield negative on minixfs.



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

  Powered by Linux