@@ -89,12 +89,14 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)
8989 return - EIO ;
9090}
9191
92- static bool exfat_allow_set_time (struct exfat_sb_info * sbi , struct inode * inode )
92+ static bool exfat_allow_set_time (struct mnt_idmap * idmap ,
93+ struct exfat_sb_info * sbi , struct inode * inode )
9394{
9495 mode_t allow_utime = sbi -> options .allow_utime ;
9596
96- if (!uid_eq (current_fsuid (), inode -> i_uid )) {
97- if (in_group_p (inode -> i_gid ))
97+ if (!vfsuid_eq_kuid (i_uid_into_vfsuid (idmap , inode ),
98+ current_fsuid ())) {
99+ if (vfsgid_in_group_p (i_gid_into_vfsgid (idmap , inode )))
98100 allow_utime >>= 3 ;
99101 if (allow_utime & MAY_WRITE )
100102 return true;
@@ -283,7 +285,7 @@ int exfat_getattr(struct mnt_idmap *idmap, const struct path *path,
283285 struct inode * inode = d_backing_inode (path -> dentry );
284286 struct exfat_inode_info * ei = EXFAT_I (inode );
285287
286- generic_fillattr (& nop_mnt_idmap , request_mask , inode , stat );
288+ generic_fillattr (idmap , request_mask , inode , stat );
287289 exfat_truncate_atime (& stat -> atime );
288290 stat -> result_mask |= STATX_BTIME ;
289291 stat -> btime .tv_sec = ei -> i_crtime .tv_sec ;
@@ -311,20 +313,22 @@ int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
311313 /* Check for setting the inode time. */
312314 ia_valid = attr -> ia_valid ;
313315 if ((ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET )) &&
314- exfat_allow_set_time (sbi , inode )) {
316+ exfat_allow_set_time (idmap , sbi , inode )) {
315317 attr -> ia_valid &= ~(ATTR_MTIME_SET | ATTR_ATIME_SET |
316318 ATTR_TIMES_SET );
317319 }
318320
319- error = setattr_prepare (& nop_mnt_idmap , dentry , attr );
321+ error = setattr_prepare (idmap , dentry , attr );
320322 attr -> ia_valid = ia_valid ;
321323 if (error )
322324 goto out ;
323325
324326 if (((attr -> ia_valid & ATTR_UID ) &&
325- !uid_eq (attr -> ia_uid , sbi -> options .fs_uid )) ||
327+ (!uid_eq (from_vfsuid (idmap , i_user_ns (inode ), attr -> ia_vfsuid ),
328+ sbi -> options .fs_uid ))) ||
326329 ((attr -> ia_valid & ATTR_GID ) &&
327- !gid_eq (attr -> ia_gid , sbi -> options .fs_gid )) ||
330+ (!gid_eq (from_vfsgid (idmap , i_user_ns (inode ), attr -> ia_vfsgid ),
331+ sbi -> options .fs_gid ))) ||
328332 ((attr -> ia_valid & ATTR_MODE ) &&
329333 (attr -> ia_mode & ~(S_IFREG | S_IFLNK | S_IFDIR | 0777 )))) {
330334 error = - EPERM ;
@@ -343,7 +347,7 @@ int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
343347 if (attr -> ia_valid & ATTR_SIZE )
344348 inode_set_mtime_to_ts (inode , inode_set_ctime_current (inode ));
345349
346- setattr_copy (& nop_mnt_idmap , inode , attr );
350+ setattr_copy (idmap , inode , attr );
347351 exfat_truncate_inode_atime (inode );
348352
349353 if (attr -> ia_valid & ATTR_SIZE ) {
0 commit comments