From: Al Viro <viro@zeniv.linux.org.uk>
To: Miklos Szeredi <mszeredi@redhat.com>
Cc: linux-fsdevel@vger.kernel.org,
Amir Goldstein <amir73il@gmail.com>,
David Howells <dhowells@redhat.com>,
Yu-li Lin <yulilin@google.com>,
Chirantan Ekbote <chirantan@chromium.org>
Subject: Re: [PATCH v2 6/8] vfs: move open right after ->tmpfile()
Date: Tue, 20 Sep 2022 02:40:32 +0100 [thread overview]
Message-ID: <YykaEI5BQ9nem3eW@ZenIV> (raw)
In-Reply-To: <20220919141031.1834447-7-mszeredi@redhat.com>
On Mon, Sep 19, 2022 at 04:10:29PM +0200, Miklos Szeredi wrote:
> - child = d_alloc(dentry, &slash_name);
> + child = d_alloc(parentpath->dentry, &slash_name);
> if (unlikely(!child))
> goto out_err;
> + file->f_path.mnt = parentpath->mnt;
> + file->f_path.dentry = child;
> mode = vfs_prepare_mode(mnt_userns, dir, mode, mode, mode);
> error = dir->i_op->tmpfile(mnt_userns, dir, child, mode);
> + error = finish_open_simple(file, error);
> + dput(child);
> + if (error)
> + goto out_err;
> + error = may_open(mnt_userns, &file->f_path, 0, file->f_flags);
> if (error)
> goto out_err;
> error = -ENOENT;
> inode = child->d_inode;
> if (unlikely(!inode))
> goto out_err;
Ugh... First of all, goto out_err leading to immediate return error;
is obfuscation for no good reason. What's more, how the hell can
we get a negative dentry here? The only thing that makes this check
valid is that after successful open child is pinned as file->f_path.dentry -
otherwise dput() above might have very well freed it. And if we ever
end up with a negative dentry in file->f_path.dentry of an opened
file, we are really screwed...
next prev parent reply other threads:[~2022-09-20 1:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-19 14:10 [PATCH v2 0/8] fuse tmpfile Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 1/8] cachefiles: tmpfile error handling cleanup Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 2/8] vfs: add tmpfile_open() helper Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 3/8] cachefiles: use " Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 4/8] ovl: " Miklos Szeredi
2022-09-20 1:33 ` Al Viro
2022-09-20 8:02 ` Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 5/8] vfs: make vfs_tmpfile() static Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 6/8] vfs: move open right after ->tmpfile() Miklos Szeredi
2022-09-20 1:40 ` Al Viro [this message]
2022-09-20 8:08 ` Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 7/8] vfs: open inside ->tmpfile() Miklos Szeredi
2022-09-20 1:50 ` Al Viro
2022-09-20 8:44 ` Miklos Szeredi
2022-09-19 14:10 ` [PATCH v2 8/8] fuse: implement ->tmpfile() Miklos Szeredi
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=YykaEI5BQ9nem3eW@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=amir73il@gmail.com \
--cc=chirantan@chromium.org \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=yulilin@google.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