diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/namei.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/namei.c b/fs/namei.c index 41445e7fd339..c6b996817bb3 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -2201,6 +2201,7 @@ static struct file *do_last(struct nameidata *nd, struct path *path, | |||
2201 | int acc_mode = op->acc_mode; | 2201 | int acc_mode = op->acc_mode; |
2202 | struct file *filp; | 2202 | struct file *filp; |
2203 | struct inode *inode; | 2203 | struct inode *inode; |
2204 | int symlink_ok = 0; | ||
2204 | int error; | 2205 | int error; |
2205 | 2206 | ||
2206 | nd->flags &= ~LOOKUP_PARENT; | 2207 | nd->flags &= ~LOOKUP_PARENT; |
@@ -2232,7 +2233,6 @@ static struct file *do_last(struct nameidata *nd, struct path *path, | |||
2232 | } | 2233 | } |
2233 | 2234 | ||
2234 | if (!(open_flag & O_CREAT)) { | 2235 | if (!(open_flag & O_CREAT)) { |
2235 | int symlink_ok = 0; | ||
2236 | if (nd->last.name[nd->last.len]) | 2236 | if (nd->last.name[nd->last.len]) |
2237 | nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; | 2237 | nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; |
2238 | if (open_flag & O_PATH && !(nd->flags & LOOKUP_FOLLOW)) | 2238 | if (open_flag & O_PATH && !(nd->flags & LOOKUP_FOLLOW)) |
@@ -2364,8 +2364,16 @@ static struct file *do_last(struct nameidata *nd, struct path *path, | |||
2364 | if (!inode) | 2364 | if (!inode) |
2365 | goto exit_dput; | 2365 | goto exit_dput; |
2366 | 2366 | ||
2367 | if (inode->i_op->follow_link) | 2367 | if (should_follow_link(inode, !symlink_ok)) { |
2368 | if (nd->flags & LOOKUP_RCU) { | ||
2369 | if (unlikely(unlazy_walk(nd, path->dentry))) { | ||
2370 | error = -ECHILD; | ||
2371 | goto exit; | ||
2372 | } | ||
2373 | } | ||
2374 | BUG_ON(inode != path->dentry->d_inode); | ||
2368 | return NULL; | 2375 | return NULL; |
2376 | } | ||
2369 | 2377 | ||
2370 | path_to_nameidata(path, nd); | 2378 | path_to_nameidata(path, nd); |
2371 | nd->inode = inode; | 2379 | nd->inode = inode; |