aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-12-26 22:33:24 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2016-01-04 10:28:40 -0500
commit62fb4a155f745285d9b1640c3ef53bf90c12f17c (patch)
treefbda98158c327b3afa13b7233a2822207b06cb8f /fs/namei.c
parentb40ef8696fbbb1107fbe5f4afc21c357f16e5ffc (diff)
don't carry MAY_OPEN in op->acc_mode
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 9e102aca3480..45c702edce3c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2663,10 +2663,6 @@ static int may_open(struct path *path, int acc_mode, int flag)
2663 struct inode *inode = dentry->d_inode; 2663 struct inode *inode = dentry->d_inode;
2664 int error; 2664 int error;
2665 2665
2666 /* O_PATH? */
2667 if (!acc_mode)
2668 return 0;
2669
2670 if (!inode) 2666 if (!inode)
2671 return -ENOENT; 2667 return -ENOENT;
2672 2668
@@ -2688,7 +2684,7 @@ static int may_open(struct path *path, int acc_mode, int flag)
2688 break; 2684 break;
2689 } 2685 }
2690 2686
2691 error = inode_permission(inode, acc_mode); 2687 error = inode_permission(inode, MAY_OPEN | acc_mode);
2692 if (error) 2688 if (error)
2693 return error; 2689 return error;
2694 2690
@@ -2880,7 +2876,7 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
2880 if (*opened & FILE_CREATED) { 2876 if (*opened & FILE_CREATED) {
2881 WARN_ON(!(open_flag & O_CREAT)); 2877 WARN_ON(!(open_flag & O_CREAT));
2882 fsnotify_create(dir, dentry); 2878 fsnotify_create(dir, dentry);
2883 acc_mode = MAY_OPEN; 2879 acc_mode = 0;
2884 } 2880 }
2885 error = may_open(&file->f_path, acc_mode, open_flag); 2881 error = may_open(&file->f_path, acc_mode, open_flag);
2886 if (error) 2882 if (error)
@@ -3093,7 +3089,7 @@ retry_lookup:
3093 /* Don't check for write permission, don't truncate */ 3089 /* Don't check for write permission, don't truncate */
3094 open_flag &= ~O_TRUNC; 3090 open_flag &= ~O_TRUNC;
3095 will_truncate = false; 3091 will_truncate = false;
3096 acc_mode = MAY_OPEN; 3092 acc_mode = 0;
3097 path_to_nameidata(&path, nd); 3093 path_to_nameidata(&path, nd);
3098 goto finish_open_created; 3094 goto finish_open_created;
3099 } 3095 }
@@ -3177,10 +3173,11 @@ finish_open:
3177 got_write = true; 3173 got_write = true;
3178 } 3174 }
3179finish_open_created: 3175finish_open_created:
3180 error = may_open(&nd->path, acc_mode, open_flag); 3176 if (likely(!(open_flag & O_PATH))) {
3181 if (error) 3177 error = may_open(&nd->path, acc_mode, open_flag);
3182 goto out; 3178 if (error)
3183 3179 goto out;
3180 }
3184 BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */ 3181 BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */
3185 error = vfs_open(&nd->path, file, current_cred()); 3182 error = vfs_open(&nd->path, file, current_cred());
3186 if (!error) { 3183 if (!error) {
@@ -3267,7 +3264,7 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags,
3267 goto out2; 3264 goto out2;
3268 audit_inode(nd->name, child, 0); 3265 audit_inode(nd->name, child, 0);
3269 /* Don't check for other permissions, the inode was just created */ 3266 /* Don't check for other permissions, the inode was just created */
3270 error = may_open(&path, MAY_OPEN, op->open_flag); 3267 error = may_open(&path, 0, op->open_flag);
3271 if (error) 3268 if (error)
3272 goto out2; 3269 goto out2;
3273 file->f_path.mnt = path.mnt; 3270 file->f_path.mnt = path.mnt;