diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2013-10-01 10:44:54 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-10-24 23:41:37 -0400 |
commit | b70a80e7a133a0c86f2fa078e7c144597c516415 (patch) | |
tree | 378dbeeafc1510fb326eda10e1f48085be098f6c /fs/dcache.c | |
parent | 94e92a6e772e009e27083a7f42d49a179e5f668c (diff) |
vfs: introduce d_instantiate_no_diralias()
...which just returns -EBUSY if a directory alias would be created.
This is to be used by fuse mkdir to make sure that a buggy or malicious
userspace filesystem doesn't do anything nasty. Previously fuse used a
private mutex for this purpose, which can now go away.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r-- | fs/dcache.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index d888223a5486..c8e83d0d61ac 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -1801,6 +1801,33 @@ struct dentry *d_instantiate_unique(struct dentry *entry, struct inode *inode) | |||
1801 | 1801 | ||
1802 | EXPORT_SYMBOL(d_instantiate_unique); | 1802 | EXPORT_SYMBOL(d_instantiate_unique); |
1803 | 1803 | ||
1804 | /** | ||
1805 | * d_instantiate_no_diralias - instantiate a non-aliased dentry | ||
1806 | * @entry: dentry to complete | ||
1807 | * @inode: inode to attach to this dentry | ||
1808 | * | ||
1809 | * Fill in inode information in the entry. If a directory alias is found, then | ||
1810 | * return an error (and drop inode). Together with d_materialise_unique() this | ||
1811 | * guarantees that a directory inode may never have more than one alias. | ||
1812 | */ | ||
1813 | int d_instantiate_no_diralias(struct dentry *entry, struct inode *inode) | ||
1814 | { | ||
1815 | BUG_ON(!hlist_unhashed(&entry->d_alias)); | ||
1816 | |||
1817 | spin_lock(&inode->i_lock); | ||
1818 | if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry)) { | ||
1819 | spin_unlock(&inode->i_lock); | ||
1820 | iput(inode); | ||
1821 | return -EBUSY; | ||
1822 | } | ||
1823 | __d_instantiate(entry, inode); | ||
1824 | spin_unlock(&inode->i_lock); | ||
1825 | security_d_instantiate(entry, inode); | ||
1826 | |||
1827 | return 0; | ||
1828 | } | ||
1829 | EXPORT_SYMBOL(d_instantiate_no_diralias); | ||
1830 | |||
1804 | struct dentry *d_make_root(struct inode *root_inode) | 1831 | struct dentry *d_make_root(struct inode *root_inode) |
1805 | { | 1832 | { |
1806 | struct dentry *res = NULL; | 1833 | struct dentry *res = NULL; |