[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 74 return 1; 75 75 } 76 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 + 77 90 static struct dentry_operations fuse_dentry_operations = { 78 91 .d_revalidate = fuse_dentry_revalidate, 79 92 }; ··· 276 263 fuse_put_request(fc, req); 277 264 278 265 /* Don't allow userspace to do really stupid things... */ 279 - if ((inode->i_mode ^ mode) & S_IFMT) { 266 + if (((inode->i_mode ^ mode) & S_IFMT) || dir_alias(inode)) { 280 267 iput(inode); 281 268 return -EIO; 282 269 } ··· 887 874 err = fuse_lookup_iget(dir, entry, &inode); 888 875 if (err) 889 876 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 - } 877 + if (inode && dir_alias(inode)) { 878 + iput(inode); 879 + return ERR_PTR(-EIO); 898 880 } 899 881 d_add(entry, inode); 900 882 return NULL;