diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-25 15:53:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-25 15:53:15 -0400 |
commit | 0003230e8200699860f0b10af524dc47bf8aecad (patch) | |
tree | 8addb0c889b32111d6973c46cd3d0a5b5c17606c /fs/9p | |
parent | 4b478cedcdc1b2d131170f22bd3f916e53472f52 (diff) | |
parent | 4e34e719e457f2e031297175410fc0bd4016a085 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
fs: take the ACL checks to common code
bury posix_acl_..._masq() variants
kill boilerplates around posix_acl_create_masq()
generic_acl: no need to clone acl just to push it to set_cached_acl()
kill boilerplate around posix_acl_chmod_masq()
reiserfs: cache negative ACLs for v1 stat format
xfs: cache negative ACLs if there is no attribute fork
9p: do no return 0 from ->check_acl without actually checking
vfs: move ACL cache lookup into generic code
CIFS: Fix oops while mounting with prefixpath
xfs: Fix wrong return value of xfs_file_aio_write
fix devtmpfs race
caam: don't pass bogus S_IFCHR to debugfs_create_...()
get rid of create_proc_entry() abuses - proc_mkdir() is there for purpose
asus-wmi: ->is_visible() can't return negative
fix jffs2 ACLs on big-endian with 16bit mode_t
9p: close ACL leaks
ocfs2_init_acl(): fix a leak
VFS : mount lock scalability for internal mounts
Diffstat (limited to 'fs/9p')
-rw-r--r-- | fs/9p/acl.c | 68 | ||||
-rw-r--r-- | fs/9p/acl.h | 10 | ||||
-rw-r--r-- | fs/9p/vfs_inode_dotl.c | 13 |
3 files changed, 36 insertions, 55 deletions
diff --git a/fs/9p/acl.c b/fs/9p/acl.c index e98f56d3787d..814be079c185 100644 --- a/fs/9p/acl.c +++ b/fs/9p/acl.c | |||
@@ -96,14 +96,11 @@ static struct posix_acl *v9fs_get_cached_acl(struct inode *inode, int type) | |||
96 | return acl; | 96 | return acl; |
97 | } | 97 | } |
98 | 98 | ||
99 | int v9fs_check_acl(struct inode *inode, int mask) | 99 | struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type) |
100 | { | 100 | { |
101 | struct posix_acl *acl; | 101 | struct posix_acl *acl; |
102 | struct v9fs_session_info *v9ses; | 102 | struct v9fs_session_info *v9ses; |
103 | 103 | ||
104 | if (mask & MAY_NOT_BLOCK) | ||
105 | return -ECHILD; | ||
106 | |||
107 | v9ses = v9fs_inode2v9ses(inode); | 104 | v9ses = v9fs_inode2v9ses(inode); |
108 | if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) || | 105 | if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) || |
109 | ((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) { | 106 | ((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) { |
@@ -111,18 +108,10 @@ int v9fs_check_acl(struct inode *inode, int mask) | |||
111 | * On access = client and acl = on mode get the acl | 108 | * On access = client and acl = on mode get the acl |
112 | * values from the server | 109 | * values from the server |
113 | */ | 110 | */ |
114 | return 0; | 111 | return NULL; |
115 | } | 112 | } |
116 | acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS); | 113 | return v9fs_get_cached_acl(inode, type); |
117 | 114 | ||
118 | if (IS_ERR(acl)) | ||
119 | return PTR_ERR(acl); | ||
120 | if (acl) { | ||
121 | int error = posix_acl_permission(inode, acl, mask); | ||
122 | posix_acl_release(acl); | ||
123 | return error; | ||
124 | } | ||
125 | return -EAGAIN; | ||
126 | } | 115 | } |
127 | 116 | ||
128 | static int v9fs_set_acl(struct dentry *dentry, int type, struct posix_acl *acl) | 117 | static int v9fs_set_acl(struct dentry *dentry, int type, struct posix_acl *acl) |
@@ -165,32 +154,32 @@ err_free_out: | |||
165 | int v9fs_acl_chmod(struct dentry *dentry) | 154 | int v9fs_acl_chmod(struct dentry *dentry) |
166 | { | 155 | { |
167 | int retval = 0; | 156 | int retval = 0; |
168 | struct posix_acl *acl, *clone; | 157 | struct posix_acl *acl; |
169 | struct inode *inode = dentry->d_inode; | 158 | struct inode *inode = dentry->d_inode; |
170 | 159 | ||
171 | if (S_ISLNK(inode->i_mode)) | 160 | if (S_ISLNK(inode->i_mode)) |
172 | return -EOPNOTSUPP; | 161 | return -EOPNOTSUPP; |
173 | acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS); | 162 | acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS); |
174 | if (acl) { | 163 | if (acl) { |
175 | clone = posix_acl_clone(acl, GFP_KERNEL); | 164 | retval = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); |
165 | if (retval) | ||
166 | return retval; | ||
167 | retval = v9fs_set_acl(dentry, ACL_TYPE_ACCESS, acl); | ||
176 | posix_acl_release(acl); | 168 | posix_acl_release(acl); |
177 | if (!clone) | ||
178 | return -ENOMEM; | ||
179 | retval = posix_acl_chmod_masq(clone, inode->i_mode); | ||
180 | if (!retval) | ||
181 | retval = v9fs_set_acl(dentry, ACL_TYPE_ACCESS, clone); | ||
182 | posix_acl_release(clone); | ||
183 | } | 169 | } |
184 | return retval; | 170 | return retval; |
185 | } | 171 | } |
186 | 172 | ||
187 | int v9fs_set_create_acl(struct dentry *dentry, | 173 | int v9fs_set_create_acl(struct dentry *dentry, |
188 | struct posix_acl *dpacl, struct posix_acl *pacl) | 174 | struct posix_acl **dpacl, struct posix_acl **pacl) |
189 | { | 175 | { |
190 | v9fs_set_acl(dentry, ACL_TYPE_DEFAULT, dpacl); | 176 | if (dentry) { |
191 | v9fs_set_acl(dentry, ACL_TYPE_ACCESS, pacl); | 177 | v9fs_set_acl(dentry, ACL_TYPE_DEFAULT, *dpacl); |
192 | posix_acl_release(dpacl); | 178 | v9fs_set_acl(dentry, ACL_TYPE_ACCESS, *pacl); |
193 | posix_acl_release(pacl); | 179 | } |
180 | posix_acl_release(*dpacl); | ||
181 | posix_acl_release(*pacl); | ||
182 | *dpacl = *pacl = NULL; | ||
194 | return 0; | 183 | return 0; |
195 | } | 184 | } |
196 | 185 | ||
@@ -209,29 +198,18 @@ int v9fs_acl_mode(struct inode *dir, mode_t *modep, | |||
209 | mode &= ~current_umask(); | 198 | mode &= ~current_umask(); |
210 | } | 199 | } |
211 | if (acl) { | 200 | if (acl) { |
212 | struct posix_acl *clone; | ||
213 | |||
214 | if (S_ISDIR(mode)) | 201 | if (S_ISDIR(mode)) |
215 | *dpacl = acl; | 202 | *dpacl = posix_acl_dup(acl); |
216 | clone = posix_acl_clone(acl, GFP_NOFS); | 203 | retval = posix_acl_create(&acl, GFP_NOFS, &mode); |
217 | retval = -ENOMEM; | 204 | if (retval < 0) |
218 | if (!clone) | 205 | return retval; |
219 | goto cleanup; | ||
220 | |||
221 | retval = posix_acl_create_masq(clone, &mode); | ||
222 | if (retval < 0) { | ||
223 | posix_acl_release(clone); | ||
224 | goto cleanup; | ||
225 | } | ||
226 | if (retval > 0) | 206 | if (retval > 0) |
227 | *pacl = clone; | 207 | *pacl = acl; |
208 | else | ||
209 | posix_acl_release(acl); | ||
228 | } | 210 | } |
229 | *modep = mode; | 211 | *modep = mode; |
230 | return 0; | 212 | return 0; |
231 | cleanup: | ||
232 | posix_acl_release(acl); | ||
233 | return retval; | ||
234 | |||
235 | } | 213 | } |
236 | 214 | ||
237 | static int v9fs_remote_get_acl(struct dentry *dentry, const char *name, | 215 | static int v9fs_remote_get_acl(struct dentry *dentry, const char *name, |
diff --git a/fs/9p/acl.h b/fs/9p/acl.h index 59e18c2e8c7e..ddb7ae19d971 100644 --- a/fs/9p/acl.h +++ b/fs/9p/acl.h | |||
@@ -16,14 +16,14 @@ | |||
16 | 16 | ||
17 | #ifdef CONFIG_9P_FS_POSIX_ACL | 17 | #ifdef CONFIG_9P_FS_POSIX_ACL |
18 | extern int v9fs_get_acl(struct inode *, struct p9_fid *); | 18 | extern int v9fs_get_acl(struct inode *, struct p9_fid *); |
19 | extern int v9fs_check_acl(struct inode *inode, int mask); | 19 | extern struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type); |
20 | extern int v9fs_acl_chmod(struct dentry *); | 20 | extern int v9fs_acl_chmod(struct dentry *); |
21 | extern int v9fs_set_create_acl(struct dentry *, | 21 | extern int v9fs_set_create_acl(struct dentry *, |
22 | struct posix_acl *, struct posix_acl *); | 22 | struct posix_acl **, struct posix_acl **); |
23 | extern int v9fs_acl_mode(struct inode *dir, mode_t *modep, | 23 | extern int v9fs_acl_mode(struct inode *dir, mode_t *modep, |
24 | struct posix_acl **dpacl, struct posix_acl **pacl); | 24 | struct posix_acl **dpacl, struct posix_acl **pacl); |
25 | #else | 25 | #else |
26 | #define v9fs_check_acl NULL | 26 | #define v9fs_iop_get_acl NULL |
27 | static inline int v9fs_get_acl(struct inode *inode, struct p9_fid *fid) | 27 | static inline int v9fs_get_acl(struct inode *inode, struct p9_fid *fid) |
28 | { | 28 | { |
29 | return 0; | 29 | return 0; |
@@ -33,8 +33,8 @@ static inline int v9fs_acl_chmod(struct dentry *dentry) | |||
33 | return 0; | 33 | return 0; |
34 | } | 34 | } |
35 | static inline int v9fs_set_create_acl(struct dentry *dentry, | 35 | static inline int v9fs_set_create_acl(struct dentry *dentry, |
36 | struct posix_acl *dpacl, | 36 | struct posix_acl **dpacl, |
37 | struct posix_acl *pacl) | 37 | struct posix_acl **pacl) |
38 | { | 38 | { |
39 | return 0; | 39 | return 0; |
40 | } | 40 | } |
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 276f4a69ecd4..9a26dce5a99f 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c | |||
@@ -287,7 +287,7 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, | |||
287 | goto error; | 287 | goto error; |
288 | 288 | ||
289 | /* Now set the ACL based on the default value */ | 289 | /* Now set the ACL based on the default value */ |
290 | v9fs_set_create_acl(dentry, dacl, pacl); | 290 | v9fs_set_create_acl(dentry, &dacl, &pacl); |
291 | 291 | ||
292 | v9inode = V9FS_I(inode); | 292 | v9inode = V9FS_I(inode); |
293 | mutex_lock(&v9inode->v_mutex); | 293 | mutex_lock(&v9inode->v_mutex); |
@@ -328,6 +328,7 @@ error: | |||
328 | err_clunk_old_fid: | 328 | err_clunk_old_fid: |
329 | if (ofid) | 329 | if (ofid) |
330 | p9_client_clunk(ofid); | 330 | p9_client_clunk(ofid); |
331 | v9fs_set_create_acl(NULL, &dacl, &pacl); | ||
331 | return err; | 332 | return err; |
332 | } | 333 | } |
333 | 334 | ||
@@ -421,12 +422,13 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir, | |||
421 | d_instantiate(dentry, inode); | 422 | d_instantiate(dentry, inode); |
422 | } | 423 | } |
423 | /* Now set the ACL based on the default value */ | 424 | /* Now set the ACL based on the default value */ |
424 | v9fs_set_create_acl(dentry, dacl, pacl); | 425 | v9fs_set_create_acl(dentry, &dacl, &pacl); |
425 | inc_nlink(dir); | 426 | inc_nlink(dir); |
426 | v9fs_invalidate_inode_attr(dir); | 427 | v9fs_invalidate_inode_attr(dir); |
427 | error: | 428 | error: |
428 | if (fid) | 429 | if (fid) |
429 | p9_client_clunk(fid); | 430 | p9_client_clunk(fid); |
431 | v9fs_set_create_acl(NULL, &dacl, &pacl); | ||
430 | return err; | 432 | return err; |
431 | } | 433 | } |
432 | 434 | ||
@@ -826,10 +828,11 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode, | |||
826 | d_instantiate(dentry, inode); | 828 | d_instantiate(dentry, inode); |
827 | } | 829 | } |
828 | /* Now set the ACL based on the default value */ | 830 | /* Now set the ACL based on the default value */ |
829 | v9fs_set_create_acl(dentry, dacl, pacl); | 831 | v9fs_set_create_acl(dentry, &dacl, &pacl); |
830 | error: | 832 | error: |
831 | if (fid) | 833 | if (fid) |
832 | p9_client_clunk(fid); | 834 | p9_client_clunk(fid); |
835 | v9fs_set_create_acl(NULL, &dacl, &pacl); | ||
833 | return err; | 836 | return err; |
834 | } | 837 | } |
835 | 838 | ||
@@ -914,7 +917,7 @@ const struct inode_operations v9fs_dir_inode_operations_dotl = { | |||
914 | .getxattr = generic_getxattr, | 917 | .getxattr = generic_getxattr, |
915 | .removexattr = generic_removexattr, | 918 | .removexattr = generic_removexattr, |
916 | .listxattr = v9fs_listxattr, | 919 | .listxattr = v9fs_listxattr, |
917 | .check_acl = v9fs_check_acl, | 920 | .get_acl = v9fs_iop_get_acl, |
918 | }; | 921 | }; |
919 | 922 | ||
920 | const struct inode_operations v9fs_file_inode_operations_dotl = { | 923 | const struct inode_operations v9fs_file_inode_operations_dotl = { |
@@ -924,7 +927,7 @@ const struct inode_operations v9fs_file_inode_operations_dotl = { | |||
924 | .getxattr = generic_getxattr, | 927 | .getxattr = generic_getxattr, |
925 | .removexattr = generic_removexattr, | 928 | .removexattr = generic_removexattr, |
926 | .listxattr = v9fs_listxattr, | 929 | .listxattr = v9fs_listxattr, |
927 | .check_acl = v9fs_check_acl, | 930 | .get_acl = v9fs_iop_get_acl, |
928 | }; | 931 | }; |
929 | 932 | ||
930 | const struct inode_operations v9fs_symlink_inode_operations_dotl = { | 933 | const struct inode_operations v9fs_symlink_inode_operations_dotl = { |