summaryrefslogtreecommitdiffstats
path: root/fs/inode.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-07-01 11:25:35 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2019-07-01 11:25:35 -0400
commit7b0e492e6b80d51db4156996b248522c7b50d467 (patch)
tree7b7e23b0a4bc9c2a97b1af4cb977cf0a5033ca59 /fs/inode.c
parent5aca284210ce827f780ea2f4f9c6ab8d6e2d6648 (diff)
vfs: create a generic checking function for FS_IOC_FSSETXATTR
Create a generic checking function for the incoming FS_IOC_FSSETXATTR fsxattr values so that we can standardize some of the implementation behaviors. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/inode.c')
-rw-r--r--fs/inode.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/fs/inode.c b/fs/inode.c
index 8072a09fd0b9..ba2bafa22885 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2194,3 +2194,26 @@ int vfs_ioc_setflags_prepare(struct inode *inode, unsigned int oldflags,
2194 return 0; 2194 return 0;
2195} 2195}
2196EXPORT_SYMBOL(vfs_ioc_setflags_prepare); 2196EXPORT_SYMBOL(vfs_ioc_setflags_prepare);
2197
2198/*
2199 * Generic function to check FS_IOC_FSSETXATTR values and reject any invalid
2200 * configurations.
2201 *
2202 * Note: the caller should be holding i_mutex, or else be sure that they have
2203 * exclusive access to the inode structure.
2204 */
2205int vfs_ioc_fssetxattr_check(struct inode *inode, const struct fsxattr *old_fa,
2206 struct fsxattr *fa)
2207{
2208 /*
2209 * Can't modify an immutable/append-only file unless we have
2210 * appropriate permission.
2211 */
2212 if ((old_fa->fsx_xflags ^ fa->fsx_xflags) &
2213 (FS_XFLAG_IMMUTABLE | FS_XFLAG_APPEND) &&
2214 !capable(CAP_LINUX_IMMUTABLE))
2215 return -EPERM;
2216
2217 return 0;
2218}
2219EXPORT_SYMBOL(vfs_ioc_fssetxattr_check);