[PATCH] fuse: check directory aliasing in mkdir

Check the created directory inode for aliases in the mkdir() method.

Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Miklos Szeredi and committed by
Linus Torvalds
f007d5c9 ea164d73

+17 -9
+17 -9
fs/fuse/dir.c
··· 74 return 1; 75 } 76 77 static struct dentry_operations fuse_dentry_operations = { 78 .d_revalidate = fuse_dentry_revalidate, 79 }; ··· 276 fuse_put_request(fc, req); 277 278 /* Don't allow userspace to do really stupid things... */ 279 - if ((inode->i_mode ^ mode) & S_IFMT) { 280 iput(inode); 281 return -EIO; 282 } ··· 887 err = fuse_lookup_iget(dir, entry, &inode); 888 if (err) 889 return ERR_PTR(err); 890 - if (inode && S_ISDIR(inode->i_mode)) { 891 - /* Don't allow creating an alias to a directory */ 892 - struct dentry *alias = d_find_alias(inode); 893 - if (alias) { 894 - dput(alias); 895 - iput(inode); 896 - return ERR_PTR(-EIO); 897 - } 898 } 899 d_add(entry, inode); 900 return NULL;
··· 74 return 1; 75 } 76 77 + static int dir_alias(struct inode *inode) 78 + { 79 + if (S_ISDIR(inode->i_mode)) { 80 + /* Don't allow creating an alias to a directory */ 81 + struct dentry *alias = d_find_alias(inode); 82 + if (alias) { 83 + dput(alias); 84 + return 1; 85 + } 86 + } 87 + return 0; 88 + } 89 + 90 static struct dentry_operations fuse_dentry_operations = { 91 .d_revalidate = fuse_dentry_revalidate, 92 }; ··· 263 fuse_put_request(fc, req); 264 265 /* Don't allow userspace to do really stupid things... */ 266 + if (((inode->i_mode ^ mode) & S_IFMT) || dir_alias(inode)) { 267 iput(inode); 268 return -EIO; 269 } ··· 874 err = fuse_lookup_iget(dir, entry, &inode); 875 if (err) 876 return ERR_PTR(err); 877 + if (inode && dir_alias(inode)) { 878 + iput(inode); 879 + return ERR_PTR(-EIO); 880 } 881 d_add(entry, inode); 882 return NULL;