aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2013-10-02 17:01:18 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-11-09 00:16:31 -0500
commitb7a6ec52dd4eced4a9bcda9ca85b3c8af84d3c90 (patch)
tree65f94ff93032bbf7ada265b89c5554cd94522366
parent5a3cd99285dc793a4022fa75ceeb323eb6d29ac9 (diff)
vfs: split out vfs_getattr_nosec
The filehandle lookup code wants this version of getattr. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/stat.c31
-rw-r--r--include/linux/fs.h1
2 files changed, 26 insertions, 6 deletions
diff --git a/fs/stat.c b/fs/stat.c
index d0ea7ef75e26..ae0c3cef9927 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -37,14 +37,21 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
37 37
38EXPORT_SYMBOL(generic_fillattr); 38EXPORT_SYMBOL(generic_fillattr);
39 39
40int vfs_getattr(struct path *path, struct kstat *stat) 40/**
41 * vfs_getattr_nosec - getattr without security checks
42 * @path: file to get attributes from
43 * @stat: structure to return attributes in
44 *
45 * Get attributes without calling security_inode_getattr.
46 *
47 * Currently the only caller other than vfs_getattr is internal to the
48 * filehandle lookup code, which uses only the inode number and returns
49 * no attributes to any user. Any other code probably wants
50 * vfs_getattr.
51 */
52int vfs_getattr_nosec(struct path *path, struct kstat *stat)
41{ 53{
42 struct inode *inode = path->dentry->d_inode; 54 struct inode *inode = path->dentry->d_inode;
43 int retval;
44
45 retval = security_inode_getattr(path->mnt, path->dentry);
46 if (retval)
47 return retval;
48 55
49 if (inode->i_op->getattr) 56 if (inode->i_op->getattr)
50 return inode->i_op->getattr(path->mnt, path->dentry, stat); 57 return inode->i_op->getattr(path->mnt, path->dentry, stat);
@@ -53,6 +60,18 @@ int vfs_getattr(struct path *path, struct kstat *stat)
53 return 0; 60 return 0;
54} 61}
55 62
63EXPORT_SYMBOL(vfs_getattr_nosec);
64
65int vfs_getattr(struct path *path, struct kstat *stat)
66{
67 int retval;
68
69 retval = security_inode_getattr(path->mnt, path->dentry);
70 if (retval)
71 return retval;
72 return vfs_getattr_nosec(path, stat);
73}
74
56EXPORT_SYMBOL(vfs_getattr); 75EXPORT_SYMBOL(vfs_getattr);
57 76
58int vfs_fstat(unsigned int fd, struct kstat *stat) 77int vfs_fstat(unsigned int fd, struct kstat *stat)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e190326ac212..5e44b0893db8 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2504,6 +2504,7 @@ extern const struct inode_operations page_symlink_inode_operations;
2504extern void kfree_put_link(struct dentry *, struct nameidata *, void *); 2504extern void kfree_put_link(struct dentry *, struct nameidata *, void *);
2505extern int generic_readlink(struct dentry *, char __user *, int); 2505extern int generic_readlink(struct dentry *, char __user *, int);
2506extern void generic_fillattr(struct inode *, struct kstat *); 2506extern void generic_fillattr(struct inode *, struct kstat *);
2507int vfs_getattr_nosec(struct path *path, struct kstat *stat);
2507extern int vfs_getattr(struct path *, struct kstat *); 2508extern int vfs_getattr(struct path *, struct kstat *);
2508void __inode_add_bytes(struct inode *inode, loff_t bytes); 2509void __inode_add_bytes(struct inode *inode, loff_t bytes);
2509void inode_add_bytes(struct inode *inode, loff_t bytes); 2510void inode_add_bytes(struct inode *inode, loff_t bytes);