@@ -1749,17 +1749,29 @@ static bool update_mtime(unsigned ivalid, bool trust_local_mtime)
1749
1749
return true;
1750
1750
}
1751
1751
1752
- static void iattr_to_fattr (struct fuse_conn * fc , struct iattr * iattr ,
1753
- struct fuse_setattr_in * arg , bool trust_local_cmtime )
1752
+ static void iattr_to_fattr (struct mnt_idmap * idmap , struct fuse_conn * fc ,
1753
+ struct iattr * iattr , struct fuse_setattr_in * arg ,
1754
+ bool trust_local_cmtime )
1754
1755
{
1755
1756
unsigned ivalid = iattr -> ia_valid ;
1756
1757
1757
1758
if (ivalid & ATTR_MODE )
1758
1759
arg -> valid |= FATTR_MODE , arg -> mode = iattr -> ia_mode ;
1759
- if (ivalid & ATTR_UID )
1760
- arg -> valid |= FATTR_UID , arg -> uid = from_kuid (fc -> user_ns , iattr -> ia_uid );
1761
- if (ivalid & ATTR_GID )
1762
- arg -> valid |= FATTR_GID , arg -> gid = from_kgid (fc -> user_ns , iattr -> ia_gid );
1760
+
1761
+ if (ivalid & ATTR_UID ) {
1762
+ kuid_t fsuid = from_vfsuid (idmap , fc -> user_ns , iattr -> ia_vfsuid );
1763
+
1764
+ arg -> valid |= FATTR_UID ;
1765
+ arg -> uid = from_kuid (fc -> user_ns , fsuid );
1766
+ }
1767
+
1768
+ if (ivalid & ATTR_GID ) {
1769
+ kgid_t fsgid = from_vfsgid (idmap , fc -> user_ns , iattr -> ia_vfsgid );
1770
+
1771
+ arg -> valid |= FATTR_GID ;
1772
+ arg -> gid = from_kgid (fc -> user_ns , fsgid );
1773
+ }
1774
+
1763
1775
if (ivalid & ATTR_SIZE )
1764
1776
arg -> valid |= FATTR_SIZE , arg -> size = iattr -> ia_size ;
1765
1777
if (ivalid & ATTR_ATIME ) {
@@ -1879,8 +1891,8 @@ int fuse_flush_times(struct inode *inode, struct fuse_file *ff)
1879
1891
* vmtruncate() doesn't allow for this case, so do the rlimit checking
1880
1892
* and the actual truncation by hand.
1881
1893
*/
1882
- int fuse_do_setattr (struct dentry * dentry , struct iattr * attr ,
1883
- struct file * file )
1894
+ int fuse_do_setattr (struct mnt_idmap * idmap , struct dentry * dentry ,
1895
+ struct iattr * attr , struct file * file )
1884
1896
{
1885
1897
struct inode * inode = d_inode (dentry );
1886
1898
struct fuse_mount * fm = get_fuse_mount (inode );
@@ -1900,7 +1912,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
1900
1912
if (!fc -> default_permissions )
1901
1913
attr -> ia_valid |= ATTR_FORCE ;
1902
1914
1903
- err = setattr_prepare (& nop_mnt_idmap , dentry , attr );
1915
+ err = setattr_prepare (idmap , dentry , attr );
1904
1916
if (err )
1905
1917
return err ;
1906
1918
@@ -1959,7 +1971,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
1959
1971
1960
1972
memset (& inarg , 0 , sizeof (inarg ));
1961
1973
memset (& outarg , 0 , sizeof (outarg ));
1962
- iattr_to_fattr (fc , attr , & inarg , trust_local_cmtime );
1974
+ iattr_to_fattr (idmap , fc , attr , & inarg , trust_local_cmtime );
1963
1975
if (file ) {
1964
1976
struct fuse_file * ff = file -> private_data ;
1965
1977
inarg .valid |= FATTR_FH ;
@@ -2094,7 +2106,7 @@ static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry,
2094
2106
if (!attr -> ia_valid )
2095
2107
return 0 ;
2096
2108
2097
- ret = fuse_do_setattr (entry , attr , file );
2109
+ ret = fuse_do_setattr (idmap , entry , attr , file );
2098
2110
if (!ret ) {
2099
2111
/*
2100
2112
* If filesystem supports acls it may have updated acl xattrs in
0 commit comments