Commit b7a6ec52dd4eced4a9bcda9ca85b3c8af84d3c90
Committed by
Al Viro
1 parent
5a3cd99285
Exists in
master
and in
16 other branches
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>
Showing 2 changed files with 26 additions and 6 deletions Side-by-side Diff
fs/stat.c
... | ... | @@ -37,20 +37,39 @@ |
37 | 37 | |
38 | 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 | 54 | struct inode *inode = path->dentry->d_inode; |
43 | - int retval; | |
44 | 55 | |
45 | - retval = security_inode_getattr(path->mnt, path->dentry); | |
46 | - if (retval) | |
47 | - return retval; | |
48 | - | |
49 | 56 | if (inode->i_op->getattr) |
50 | 57 | return inode->i_op->getattr(path->mnt, path->dentry, stat); |
51 | 58 | |
52 | 59 | generic_fillattr(inode, stat); |
53 | 60 | return 0; |
61 | +} | |
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); | |
54 | 73 | } |
55 | 74 | |
56 | 75 | EXPORT_SYMBOL(vfs_getattr); |
include/linux/fs.h
... | ... | @@ -2504,6 +2504,7 @@ |
2504 | 2504 | extern void kfree_put_link(struct dentry *, struct nameidata *, void *); |
2505 | 2505 | extern int generic_readlink(struct dentry *, char __user *, int); |
2506 | 2506 | extern void generic_fillattr(struct inode *, struct kstat *); |
2507 | +int vfs_getattr_nosec(struct path *path, struct kstat *stat); | |
2507 | 2508 | extern int vfs_getattr(struct path *, struct kstat *); |
2508 | 2509 | void __inode_add_bytes(struct inode *inode, loff_t bytes); |
2509 | 2510 | void inode_add_bytes(struct inode *inode, loff_t bytes); |