diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2013-06-06 09:12:33 -0400 |
|---|---|---|
| committer | Moyster <oysterized@gmail.com> | 2019-05-02 15:58:48 +0200 |
| commit | a056f360307bfc102d6ddf533d079c3769cc5c94 (patch) | |
| tree | 5f295c3d752b431f9b7c6d72f5f4a7023d99e54d /fs/namei.c | |
| parent | bf72013b84bcc8e0f26f65f8354f7d7861d044b3 (diff) | |
do_last(): fix missing checks for LAST_BIND case
/proc/self/cwd with O_CREAT should fail with EISDIR. /proc/self/exe, OTOH,
should fail with ENOTDIR when opened with O_DIRECTORY.
Change-Id: Id0e52bc3afee67f2af1277d6bea65b073cf440d6
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
| -rw-r--r-- | fs/namei.c | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/fs/namei.c b/fs/namei.c index 36441b34c..5ef0de80d 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2764,28 +2764,10 @@ static int do_last(struct nameidata *nd, struct path *path, nd->flags &= ~LOOKUP_PARENT; nd->flags |= op->intent; - switch (nd->last_type) { - case LAST_DOTDOT: - case LAST_DOT: + if (nd->last_type != LAST_NORM) { error = handle_dots(nd, nd->last_type); if (error) return error; - /* fallthrough */ - case LAST_ROOT: - error = complete_walk(nd); - if (error) - return error; - audit_inode(name, nd->path.dentry, 0); - if (open_flag & O_CREAT) { - error = -EISDIR; - goto out; - } - goto finish_open; - case LAST_BIND: - error = complete_walk(nd); - if (error) - return error; - audit_inode(name, dir, 0); goto finish_open; } @@ -2916,19 +2898,19 @@ finish_lookup: } nd->inode = inode; /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */ +finish_open: error = complete_walk(nd); if (error) { path_put(&save_parent); return error; } + audit_inode(name, nd->path.dentry, 0); error = -EISDIR; if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode)) goto out; error = -ENOTDIR; if ((nd->flags & LOOKUP_DIRECTORY) && !can_lookup(nd->inode)) goto out; - audit_inode(name, nd->path.dentry, 0); -finish_open: if (!S_ISREG(nd->inode->i_mode)) will_truncate = false; |
