aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2018-02-21 11:59:31 -0500
committerJan Kara <jack@suse.cz>2018-02-27 04:25:33 -0500
commitecd10aa42819cd5dcf639d25575e95a5bda8d08a (patch)
treefe8b73f2a6cc6d58ba54f04b8204d341a97eb6a1 /fs/udf
parent70260e44750356fecb40ff5fcb0f91bcc911ab5f (diff)
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')
-rw-r--r--fs/udf/file.c10
-rw-r--r--fs/udf/ialloc.c4
2 files changed, 14 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 = {
257static int udf_setattr(struct dentry *dentry, struct iattr *attr) 257static int udf_setattr(struct dentry *dentry, struct iattr *attr)
258{ 258{
259 struct inode *inode = d_inode(dentry); 259 struct inode *inode = d_inode(dentry);
260 struct super_block *sb = inode->i_sb;
260 int error; 261 int error;
261 262
262 error = setattr_prepare(dentry, attr); 263 error = setattr_prepare(dentry, attr);
263 if (error) 264 if (error)
264 return error; 265 return error;
265 266
267 if ((attr->ia_valid & ATTR_UID) &&
268 UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET) &&
269 !uid_eq(attr->ia_uid, UDF_SB(sb)->s_uid))
270 return -EPERM;
271 if ((attr->ia_valid & ATTR_GID) &&
272 UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET) &&
273 !gid_eq(attr->ia_gid, UDF_SB(sb)->s_gid))
274 return -EPERM;
275
266 if ((attr->ia_valid & ATTR_SIZE) && 276 if ((attr->ia_valid & ATTR_SIZE) &&
267 attr->ia_size != i_size_read(inode)) { 277 attr->ia_size != i_size_read(inode)) {
268 error = udf_setsize(inode, attr->ia_size); 278 error = udf_setsize(inode, attr->ia_size);
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index b6e420c1bfeb..b7a0d4b4bda1 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -104,6 +104,10 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
104 } 104 }
105 105
106 inode_init_owner(inode, dir, mode); 106 inode_init_owner(inode, dir, mode);
107 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET))
108 inode->i_uid = sbi->s_uid;
109 if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET))
110 inode->i_gid = sbi->s_gid;
107 111
108 iinfo->i_location.logicalBlockNum = block; 112 iinfo->i_location.logicalBlockNum = block;
109 iinfo->i_location.partitionReferenceNum = 113 iinfo->i_location.partitionReferenceNum =