mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Qinghua Jin <qhjin_dev@163.com>
Cc: Colin Ian King <colin.king@canonical.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: 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: Tue, 4 Jan 2022 02:06:51 +0000	[thread overview]
Message-ID: <YdOru5u/Vs2+ns7B@zeniv-ca.linux.org.uk> (raw)
In-Reply-To: <20220104015358.57443-1-qhjin_dev@163.com>

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.

      reply	other threads:[~2022-01-04  2:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-04  1:53 Qinghua Jin
2022-01-04  2:06 ` Al Viro [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YdOru5u/Vs2+ns7B@zeniv-ca.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=colin.king@canonical.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qhjin_dev@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®