diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2020-01-26 09:53:19 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2020-03-13 21:09:12 -0400 |
commit | 6fb968cdf9d0bd66742ac73f3db268dcb0278ada (patch) | |
tree | ce3843adae7ad1ad5993e5715a7126f6705f6afc /fs/namei.c | |
parent | 9deed3ebca244663530782631834e706a86a8c8f (diff) |
atomic_open(): return the right dentry in FMODE_OPENED case
->atomic_open() might have used a different alias than the one we'd
passed to it; in "not opened" case we take care of that, in "opened"
one we don't. Currently we don't care downstream of "opened" case
which alias to return; however, that will change shortly when we
get to unifying may_open() calls.
It's not hard to get right in all cases, anyway.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/namei.c b/fs/namei.c index 40d5f7abfa54..88f985aff4f8 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2949,11 +2949,15 @@ static struct dentry *atomic_open(struct nameidata *nd, struct dentry *dentry, d_lookup_done(dentry); if (!error) { if (file->f_mode & FMODE_OPENED) { + int acc_mode = op->acc_mode; + if (unlikely(dentry != file->f_path.dentry)) { + dput(dentry); + dentry = dget(file->f_path.dentry); + } /* * We didn't have the inode before the open, so check open * permission here. */ - int acc_mode = op->acc_mode; if (file->f_mode & FMODE_CREATED) { WARN_ON(!(open_flag & O_CREAT)); fsnotify_create(dir, dentry); |