linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: "穆阿浩(姜弋)" <ahao.mah@alibaba-inc.com>
Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
	渡波 <dubo.sgw@alibaba-inc.com>,
	"张礼广(乱石)" <liguang.zlg@alibaba-inc.com>
Subject: Re: [PATCH] fs/vfs: Release allocated dentry on failure in do_last()
Date: Wed, 6 Dec 2017 21:30:03 -0800	[thread overview]
Message-ID: <20171207053003.GA2739@bombadil.infradead.org> (raw)
In-Reply-To: <1512614782-46982-1-git-send-email-ahao.mah@alibaba-inc.com>

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?

  reply	other threads:[~2017-12-07  5:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07  2:46 [PATCH] fs/vfs: Release allocated dentry on failure in do_last() 穆阿浩(姜弋)
2017-12-07  5:30 ` Matthew Wilcox [this message]
2017-12-08  3:14   ` 渡波
2017-12-07 12:39 ` Al Viro
2017-12-08  3:11   ` 渡波

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=20171207053003.GA2739@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=ahao.mah@alibaba-inc.com \
    --cc=dubo.sgw@alibaba-inc.com \
    --cc=liguang.zlg@alibaba-inc.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).