Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

Jan Kara ecd10aa4 70260e44

+14
+10
fs/udf/file.c
··· 257 257 static int udf_setattr(struct dentry *dentry, struct iattr *attr) 258 258 { 259 259 struct inode *inode = d_inode(dentry); 260 + struct super_block *sb = inode->i_sb; 260 261 int error; 261 262 262 263 error = setattr_prepare(dentry, attr); 263 264 if (error) 264 265 return error; 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; 265 275 266 276 if ((attr->ia_valid & ATTR_SIZE) && 267 277 attr->ia_size != i_size_read(inode)) {
+4
fs/udf/ialloc.c
··· 104 104 } 105 105 106 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 112 iinfo->i_location.logicalBlockNum = block; 109 113 iinfo->i_location.partitionReferenceNum =