diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2012-05-21 11:30:09 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-06-01 12:11:58 -0400 |
commit | d45ea86792db9679ed010b2c3df3db32b2ce5bde (patch) | |
tree | 573f99f16911ce9e14087a5559a11e876d676859 | |
parent | decf3400879d02d0eafedea52c7f208587be062a (diff) |
vfs: make follow_link check RCU safe
This will allow this code to be used in RCU mode.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-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; |