Skip to content

Commit b7a6ec5

Browse files
J. Bruce FieldsAl Viro
authored andcommitted
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>
1 parent 5a3cd99 commit b7a6ec5

2 files changed

Lines changed: 26 additions & 6 deletions

File tree

‎fs/stat.c‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,21 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
3737

3838
EXPORT_SYMBOL(generic_fillattr);
3939

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)
4153
{
4254
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;
4855

4956
if (inode->i_op->getattr)
5057
return inode->i_op->getattr(path->mnt, path->dentry, stat);
@@ -53,6 +60,18 @@ int vfs_getattr(struct path *path, struct kstat *stat)
5360
return 0;
5461
}
5562

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+
5675
EXPORT_SYMBOL(vfs_getattr);
5776

5877
int vfs_fstat(unsigned int fd, struct kstat *stat)

‎include/linux/fs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,6 +2504,7 @@ extern const struct inode_operations page_symlink_inode_operations;
25042504
extern void kfree_put_link(struct dentry *, struct nameidata *, void *);
25052505
extern int generic_readlink(struct dentry *, char __user *, int);
25062506
extern void generic_fillattr(struct inode *, struct kstat *);
2507+
int vfs_getattr_nosec(struct path *path, struct kstat *stat);
25072508
extern int vfs_getattr(struct path *, struct kstat *);
25082509
void __inode_add_bytes(struct inode *inode, loff_t bytes);
25092510
void inode_add_bytes(struct inode *inode, loff_t bytes);

0 commit comments

Comments
 (0)