@@ -1135,18 +1135,22 @@ static int fuse_link(struct dentry *entry, struct inode *newdir,
1135
1135
return err ;
1136
1136
}
1137
1137
1138
- static void fuse_fillattr (struct inode * inode , struct fuse_attr * attr ,
1139
- struct kstat * stat )
1138
+ static void fuse_fillattr (struct mnt_idmap * idmap , struct inode * inode ,
1139
+ struct fuse_attr * attr , struct kstat * stat )
1140
1140
{
1141
1141
unsigned int blkbits ;
1142
1142
struct fuse_conn * fc = get_fuse_conn (inode );
1143
+ vfsuid_t vfsuid = make_vfsuid (idmap , fc -> user_ns ,
1144
+ make_kuid (fc -> user_ns , attr -> uid ));
1145
+ vfsgid_t vfsgid = make_vfsgid (idmap , fc -> user_ns ,
1146
+ make_kgid (fc -> user_ns , attr -> gid ));
1143
1147
1144
1148
stat -> dev = inode -> i_sb -> s_dev ;
1145
1149
stat -> ino = attr -> ino ;
1146
1150
stat -> mode = (inode -> i_mode & S_IFMT ) | (attr -> mode & 07777 );
1147
1151
stat -> nlink = attr -> nlink ;
1148
- stat -> uid = make_kuid ( fc -> user_ns , attr -> uid );
1149
- stat -> gid = make_kgid ( fc -> user_ns , attr -> gid );
1152
+ stat -> uid = vfsuid_into_kuid ( vfsuid );
1153
+ stat -> gid = vfsgid_into_kgid ( vfsgid );
1150
1154
stat -> rdev = inode -> i_rdev ;
1151
1155
stat -> atime .tv_sec = attr -> atime ;
1152
1156
stat -> atime .tv_nsec = attr -> atimensec ;
@@ -1185,8 +1189,8 @@ static void fuse_statx_to_attr(struct fuse_statx *sx, struct fuse_attr *attr)
1185
1189
attr -> blksize = sx -> blksize ;
1186
1190
}
1187
1191
1188
- static int fuse_do_statx (struct inode * inode , struct file * file ,
1189
- struct kstat * stat )
1192
+ static int fuse_do_statx (struct mnt_idmap * idmap , struct inode * inode ,
1193
+ struct file * file , struct kstat * stat )
1190
1194
{
1191
1195
int err ;
1192
1196
struct fuse_attr attr ;
@@ -1239,15 +1243,15 @@ static int fuse_do_statx(struct inode *inode, struct file *file,
1239
1243
stat -> result_mask = sx -> mask & (STATX_BASIC_STATS | STATX_BTIME );
1240
1244
stat -> btime .tv_sec = sx -> btime .tv_sec ;
1241
1245
stat -> btime .tv_nsec = min_t (u32 , sx -> btime .tv_nsec , NSEC_PER_SEC - 1 );
1242
- fuse_fillattr (inode , & attr , stat );
1246
+ fuse_fillattr (idmap , inode , & attr , stat );
1243
1247
stat -> result_mask |= STATX_TYPE ;
1244
1248
}
1245
1249
1246
1250
return 0 ;
1247
1251
}
1248
1252
1249
- static int fuse_do_getattr (struct inode * inode , struct kstat * stat ,
1250
- struct file * file )
1253
+ static int fuse_do_getattr (struct mnt_idmap * idmap , struct inode * inode ,
1254
+ struct kstat * stat , struct file * file )
1251
1255
{
1252
1256
int err ;
1253
1257
struct fuse_getattr_in inarg ;
@@ -1286,15 +1290,15 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat,
1286
1290
ATTR_TIMEOUT (& outarg ),
1287
1291
attr_version );
1288
1292
if (stat )
1289
- fuse_fillattr (inode , & outarg .attr , stat );
1293
+ fuse_fillattr (idmap , inode , & outarg .attr , stat );
1290
1294
}
1291
1295
}
1292
1296
return err ;
1293
1297
}
1294
1298
1295
- static int fuse_update_get_attr (struct inode * inode , struct file * file ,
1296
- struct kstat * stat , u32 request_mask ,
1297
- unsigned int flags )
1299
+ static int fuse_update_get_attr (struct mnt_idmap * idmap , struct inode * inode ,
1300
+ struct file * file , struct kstat * stat ,
1301
+ u32 request_mask , unsigned int flags )
1298
1302
{
1299
1303
struct fuse_inode * fi = get_fuse_inode (inode );
1300
1304
struct fuse_conn * fc = get_fuse_conn (inode );
@@ -1325,17 +1329,17 @@ static int fuse_update_get_attr(struct inode *inode, struct file *file,
1325
1329
forget_all_cached_acls (inode );
1326
1330
/* Try statx if BTIME is requested */
1327
1331
if (!fc -> no_statx && (request_mask & ~STATX_BASIC_STATS )) {
1328
- err = fuse_do_statx (inode , file , stat );
1332
+ err = fuse_do_statx (idmap , inode , file , stat );
1329
1333
if (err == - ENOSYS ) {
1330
1334
fc -> no_statx = 1 ;
1331
1335
err = 0 ;
1332
1336
goto retry ;
1333
1337
}
1334
1338
} else {
1335
- err = fuse_do_getattr (inode , stat , file );
1339
+ err = fuse_do_getattr (idmap , inode , stat , file );
1336
1340
}
1337
1341
} else if (stat ) {
1338
- generic_fillattr (& nop_mnt_idmap , request_mask , inode , stat );
1342
+ generic_fillattr (idmap , request_mask , inode , stat );
1339
1343
stat -> mode = fi -> orig_i_mode ;
1340
1344
stat -> ino = fi -> orig_ino ;
1341
1345
if (test_bit (FUSE_I_BTIME , & fi -> state )) {
@@ -1349,7 +1353,7 @@ static int fuse_update_get_attr(struct inode *inode, struct file *file,
1349
1353
1350
1354
int fuse_update_attributes (struct inode * inode , struct file * file , u32 mask )
1351
1355
{
1352
- return fuse_update_get_attr (inode , file , NULL , mask , 0 );
1356
+ return fuse_update_get_attr (& nop_mnt_idmap , inode , file , NULL , mask , 0 );
1353
1357
}
1354
1358
1355
1359
int fuse_reverse_inval_entry (struct fuse_conn * fc , u64 parent_nodeid ,
@@ -1493,7 +1497,7 @@ static int fuse_perm_getattr(struct inode *inode, int mask)
1493
1497
return - ECHILD ;
1494
1498
1495
1499
forget_all_cached_acls (inode );
1496
- return fuse_do_getattr (inode , NULL , NULL );
1500
+ return fuse_do_getattr (& nop_mnt_idmap , inode , NULL , NULL );
1497
1501
}
1498
1502
1499
1503
/*
@@ -2072,7 +2076,7 @@ static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry,
2072
2076
* ia_mode calculation may have used stale i_mode.
2073
2077
* Refresh and recalculate.
2074
2078
*/
2075
- ret = fuse_do_getattr (inode , NULL , file );
2079
+ ret = fuse_do_getattr (idmap , inode , NULL , file );
2076
2080
if (ret )
2077
2081
return ret ;
2078
2082
@@ -2129,7 +2133,7 @@ static int fuse_getattr(struct mnt_idmap *idmap,
2129
2133
return - EACCES ;
2130
2134
}
2131
2135
2132
- return fuse_update_get_attr (inode , NULL , stat , request_mask , flags );
2136
+ return fuse_update_get_attr (idmap , inode , NULL , stat , request_mask , flags );
2133
2137
}
2134
2138
2135
2139
static const struct inode_operations fuse_dir_inode_operations = {
0 commit comments