From: Al Viro <viro@ZenIV.linux.org.uk>
To: "穆阿浩(姜弋)" <ahao.mah@alibaba-inc.com>
Cc: linux-fsdevel@vger.kernel.org, 渡波 <dubo.sgw@alibaba-inc.com>,
"张礼广(乱石)" <liguang.zlg@alibaba-inc.com>
Subject: Re: [PATCH] fs/vfs: Release allocated dentry on failure in do_last()
Date: Thu, 7 Dec 2017 12:39:37 +0000 [thread overview]
Message-ID: <20171207123937.GB21978@ZenIV.linux.org.uk> (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().
> # rm /dev/sdtest
> # dd if=/dev/urandom of=/dev/sdtest bs=4k count=1 oflag=direct
> <-EINVAL is returned>
> # ls /dev/sdtest
> <File is still existing>
>
> This fixes the issue by releasing the dentry, thus the inode on failure
> in do_last(). With this applied, the file (/dev/sdtest) isn't seen
> in this scenario.
> + if (error && (*opened & FILE_OPENED))
> + dput(path.dentry);
NAK. For one thing, it's racy as hell even on tmpfs - plain open()
from another process would've succeeded in that window. For another,
it's outright exploitable on filesystems where dentry tree does not
contain all the existing directory tree (anything disk-based, for
starters).
next prev parent reply other threads:[~2017-12-07 12:39 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
2017-12-08 3:14 ` 渡波
2017-12-07 12:39 ` Al Viro [this message]
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=20171207123937.GB21978@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=ahao.mah@alibaba-inc.com \
--cc=dubo.sgw@alibaba-inc.com \
--cc=liguang.zlg@alibaba-inc.com \
--cc=linux-fsdevel@vger.kernel.org \
/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).