diff options
author | J. Bruce Fields <bfields@redhat.com> | 2013-10-02 17:01:18 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-11-09 00:16:31 -0500 |
commit | b7a6ec52dd4eced4a9bcda9ca85b3c8af84d3c90 (patch) | |
tree | 65f94ff93032bbf7ada265b89c5554cd94522366 | |
parent | 5a3cd99285dc793a4022fa75ceeb323eb6d29ac9 (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.c | 31 | ||||
-rw-r--r-- | include/linux/fs.h | 1 |
2 files changed, 26 insertions, 6 deletions
@@ -37,14 +37,21 @@ void generic_fillattr(struct inode *inode, struct kstat *stat) | |||
37 | 37 | ||
38 | EXPORT_SYMBOL(generic_fillattr); | 38 | EXPORT_SYMBOL(generic_fillattr); |
39 | 39 | ||
40 | int 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 | */ | ||
52 | int 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 | ||
63 | EXPORT_SYMBOL(vfs_getattr_nosec); | ||
64 | |||
65 | int 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 | |||
56 | EXPORT_SYMBOL(vfs_getattr); | 75 | EXPORT_SYMBOL(vfs_getattr); |
57 | 76 | ||
58 | int vfs_fstat(unsigned int fd, struct kstat *stat) | 77 | int 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; | |||
2504 | extern void kfree_put_link(struct dentry *, struct nameidata *, void *); | 2504 | extern void kfree_put_link(struct dentry *, struct nameidata *, void *); |
2505 | extern int generic_readlink(struct dentry *, char __user *, int); | 2505 | extern int generic_readlink(struct dentry *, char __user *, int); |
2506 | extern void generic_fillattr(struct inode *, struct kstat *); | 2506 | extern void generic_fillattr(struct inode *, struct kstat *); |
2507 | int vfs_getattr_nosec(struct path *path, struct kstat *stat); | ||
2507 | extern int vfs_getattr(struct path *, struct kstat *); | 2508 | extern int vfs_getattr(struct path *, struct kstat *); |
2508 | void __inode_add_bytes(struct inode *inode, loff_t bytes); | 2509 | void __inode_add_bytes(struct inode *inode, loff_t bytes); |
2509 | void inode_add_bytes(struct inode *inode, loff_t bytes); | 2510 | void inode_add_bytes(struct inode *inode, loff_t bytes); |