diff options
author | Jan Kara <jack@suse.cz> | 2018-02-21 17:59:31 +0100 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2018-02-27 10:25:33 +0100 |
commit | ecd10aa42819cd5dcf639d25575e95a5bda8d08a (patch) | |
tree | fe8b73f2a6cc6d58ba54f04b8204d341a97eb6a1 /fs/udf/file.c | |
parent | 70260e44750356fecb40ff5fcb0f91bcc911ab5f (diff) | |
download | blackbird-obmc-linux-ecd10aa42819cd5dcf639d25575e95a5bda8d08a.tar.gz blackbird-obmc-linux-ecd10aa42819cd5dcf639d25575e95a5bda8d08a.zip |
udf: Apply uid/gid mount options also to new inodes & chown
Currently newly created files belong to current user despite
uid=<number> / gid=<number> mount options. This is confusing to users
(as owner of the file will change after remount / eviction from cache)
and also inconsistent with e.g. FAT with the same mount option. So apply
uid=<number> and gid=<number> also to newly created inodes and similarly
as FAT disallow to change owner of the file in this case.
Reported-by: Steve Kenton <skenton@ou.edu>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/file.c')
-rw-r--r-- | fs/udf/file.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/udf/file.c b/fs/udf/file.c index 356c2bf148a5..cd31e4f6d6da 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -257,12 +257,22 @@ const struct file_operations udf_file_operations = { static int udf_setattr(struct dentry *dentry, struct iattr *attr) { struct inode *inode = d_inode(dentry); + struct super_block *sb = inode->i_sb; int error; error = setattr_prepare(dentry, attr); if (error) return error; + if ((attr->ia_valid & ATTR_UID) && + UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET) && + !uid_eq(attr->ia_uid, UDF_SB(sb)->s_uid)) + return -EPERM; + if ((attr->ia_valid & ATTR_GID) && + UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET) && + !gid_eq(attr->ia_gid, UDF_SB(sb)->s_gid)) + return -EPERM; + if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size != i_size_read(inode)) { error = udf_setsize(inode, attr->ia_size); |