aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-07-23 02:28:13 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-24 10:10:18 -0400
commit1ec95bf34d976b38897d1977b155a544d77b05e7 (patch)
tree4ab00349b5bb528bf24631c6e80402cbbc190e42 /fs
parentc0d960f038bdfe0fa73c9f698ba836ed20b672c9 (diff)
9p: close ACL leaks
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/acl.c22
-rw-r--r--fs/9p/acl.h6
-rw-r--r--fs/9p/vfs_inode_dotl.c9
3 files changed, 22 insertions, 15 deletions
diff --git a/fs/9p/acl.c b/fs/9p/acl.c
index e98f56d3787d..7350f53f3b51 100644
--- a/fs/9p/acl.c
+++ b/fs/9p/acl.c
@@ -185,12 +185,15 @@ int v9fs_acl_chmod(struct dentry *dentry)
185} 185}
186 186
187int v9fs_set_create_acl(struct dentry *dentry, 187int v9fs_set_create_acl(struct dentry *dentry,
188 struct posix_acl *dpacl, struct posix_acl *pacl) 188 struct posix_acl **dpacl, struct posix_acl **pacl)
189{ 189{
190 v9fs_set_acl(dentry, ACL_TYPE_DEFAULT, dpacl); 190 if (dentry) {
191 v9fs_set_acl(dentry, ACL_TYPE_ACCESS, pacl); 191 v9fs_set_acl(dentry, ACL_TYPE_DEFAULT, *dpacl);
192 posix_acl_release(dpacl); 192 v9fs_set_acl(dentry, ACL_TYPE_ACCESS, *pacl);
193 posix_acl_release(pacl); 193 }
194 posix_acl_release(*dpacl);
195 posix_acl_release(*pacl);
196 *dpacl = *pacl = NULL;
194 return 0; 197 return 0;
195} 198}
196 199
@@ -212,11 +215,11 @@ int v9fs_acl_mode(struct inode *dir, mode_t *modep,
212 struct posix_acl *clone; 215 struct posix_acl *clone;
213 216
214 if (S_ISDIR(mode)) 217 if (S_ISDIR(mode))
215 *dpacl = acl; 218 *dpacl = posix_acl_dup(acl);
216 clone = posix_acl_clone(acl, GFP_NOFS); 219 clone = posix_acl_clone(acl, GFP_NOFS);
217 retval = -ENOMEM; 220 posix_acl_release(acl);
218 if (!clone) 221 if (!clone)
219 goto cleanup; 222 return -ENOMEM;
220 223
221 retval = posix_acl_create_masq(clone, &mode); 224 retval = posix_acl_create_masq(clone, &mode);
222 if (retval < 0) { 225 if (retval < 0) {
@@ -225,11 +228,12 @@ int v9fs_acl_mode(struct inode *dir, mode_t *modep,
225 } 228 }
226 if (retval > 0) 229 if (retval > 0)
227 *pacl = clone; 230 *pacl = clone;
231 else
232 posix_acl_release(clone);
228 } 233 }
229 *modep = mode; 234 *modep = mode;
230 return 0; 235 return 0;
231cleanup: 236cleanup:
232 posix_acl_release(acl);
233 return retval; 237 return retval;
234 238
235} 239}
diff --git a/fs/9p/acl.h b/fs/9p/acl.h
index 59e18c2e8c7e..3eba10f3af1e 100644
--- a/fs/9p/acl.h
+++ b/fs/9p/acl.h
@@ -19,7 +19,7 @@ extern int v9fs_get_acl(struct inode *, struct p9_fid *);
19extern int v9fs_check_acl(struct inode *inode, int mask); 19extern int v9fs_check_acl(struct inode *inode, int mask);
20extern int v9fs_acl_chmod(struct dentry *); 20extern int v9fs_acl_chmod(struct dentry *);
21extern int v9fs_set_create_acl(struct dentry *, 21extern int v9fs_set_create_acl(struct dentry *,
22 struct posix_acl *, struct posix_acl *); 22 struct posix_acl **, struct posix_acl **);
23extern int v9fs_acl_mode(struct inode *dir, mode_t *modep, 23extern 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
@@ -33,8 +33,8 @@ static inline int v9fs_acl_chmod(struct dentry *dentry)
33 return 0; 33 return 0;
34} 34}
35static inline int v9fs_set_create_acl(struct dentry *dentry, 35static 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 32bbbe5aa689..803f59ff2faa 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -242,7 +242,7 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
242 goto error; 242 goto error;
243 243
244 /* Now set the ACL based on the default value */ 244 /* Now set the ACL based on the default value */
245 v9fs_set_create_acl(dentry, dacl, pacl); 245 v9fs_set_create_acl(dentry, &dacl, &pacl);
246 246
247 v9inode = V9FS_I(inode); 247 v9inode = V9FS_I(inode);
248 mutex_lock(&v9inode->v_mutex); 248 mutex_lock(&v9inode->v_mutex);
@@ -283,6 +283,7 @@ error:
283err_clunk_old_fid: 283err_clunk_old_fid:
284 if (ofid) 284 if (ofid)
285 p9_client_clunk(ofid); 285 p9_client_clunk(ofid);
286 v9fs_set_create_acl(NULL, &dacl, &pacl);
286 return err; 287 return err;
287} 288}
288 289
@@ -376,12 +377,13 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
376 d_instantiate(dentry, inode); 377 d_instantiate(dentry, inode);
377 } 378 }
378 /* Now set the ACL based on the default value */ 379 /* Now set the ACL based on the default value */
379 v9fs_set_create_acl(dentry, dacl, pacl); 380 v9fs_set_create_acl(dentry, &dacl, &pacl);
380 inc_nlink(dir); 381 inc_nlink(dir);
381 v9fs_invalidate_inode_attr(dir); 382 v9fs_invalidate_inode_attr(dir);
382error: 383error:
383 if (fid) 384 if (fid)
384 p9_client_clunk(fid); 385 p9_client_clunk(fid);
386 v9fs_set_create_acl(NULL, &dacl, &pacl);
385 return err; 387 return err;
386} 388}
387 389
@@ -781,10 +783,11 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode,
781 d_instantiate(dentry, inode); 783 d_instantiate(dentry, inode);
782 } 784 }
783 /* Now set the ACL based on the default value */ 785 /* Now set the ACL based on the default value */
784 v9fs_set_create_acl(dentry, dacl, pacl); 786 v9fs_set_create_acl(dentry, &dacl, &pacl);
785error: 787error:
786 if (fid) 788 if (fid)
787 p9_client_clunk(fid); 789 p9_client_clunk(fid);
790 v9fs_set_create_acl(NULL, &dacl, &pacl);
788 return err; 791 return err;
789} 792}
790 793