@@ -693,7 +693,8 @@ xfs_ioc_space(
693693
694694 iattr .ia_valid = ATTR_SIZE ;
695695 iattr .ia_size = bf -> l_start ;
696- error = xfs_vn_setattr_size (file_dentry (filp ), & iattr );
696+ error = xfs_vn_setattr_size (file_mnt_user_ns (filp ), file_dentry (filp ),
697+ & iattr );
697698 if (error )
698699 goto out_unlock ;
699700
@@ -734,13 +735,15 @@ xfs_fsinumbers_fmt(
734735
735736STATIC int
736737xfs_ioc_fsbulkstat (
737- xfs_mount_t * mp ,
738+ struct file * file ,
738739 unsigned int cmd ,
739740 void __user * arg )
740741{
742+ struct xfs_mount * mp = XFS_I (file_inode (file ))-> i_mount ;
741743 struct xfs_fsop_bulkreq bulkreq ;
742744 struct xfs_ibulk breq = {
743745 .mp = mp ,
746+ .mnt_userns = file_mnt_user_ns (file ),
744747 .ocount = 0 ,
745748 };
746749 xfs_ino_t lastino ;
@@ -908,13 +911,15 @@ xfs_bulk_ireq_teardown(
908911/* Handle the v5 bulkstat ioctl. */
909912STATIC int
910913xfs_ioc_bulkstat (
911- struct xfs_mount * mp ,
914+ struct file * file ,
912915 unsigned int cmd ,
913916 struct xfs_bulkstat_req __user * arg )
914917{
918+ struct xfs_mount * mp = XFS_I (file_inode (file ))-> i_mount ;
915919 struct xfs_bulk_ireq hdr ;
916920 struct xfs_ibulk breq = {
917921 .mp = mp ,
922+ .mnt_userns = file_mnt_user_ns (file ),
918923 };
919924 int error ;
920925
@@ -1275,8 +1280,9 @@ xfs_ioctl_setattr_prepare_dax(
12751280 */
12761281static struct xfs_trans *
12771282xfs_ioctl_setattr_get_trans (
1278- struct xfs_inode * ip )
1283+ struct file * file )
12791284{
1285+ struct xfs_inode * ip = XFS_I (file_inode (file ));
12801286 struct xfs_mount * mp = ip -> i_mount ;
12811287 struct xfs_trans * tp ;
12821288 int error = - EROFS ;
@@ -1300,7 +1306,7 @@ xfs_ioctl_setattr_get_trans(
13001306 * The user ID of the calling process must be equal to the file owner
13011307 * ID, except in cases where the CAP_FSETID capability is applicable.
13021308 */
1303- if (!inode_owner_or_capable (& init_user_ns , VFS_I (ip ))) {
1309+ if (!inode_owner_or_capable (file_mnt_user_ns ( file ) , VFS_I (ip ))) {
13041310 error = - EPERM ;
13051311 goto out_cancel ;
13061312 }
@@ -1428,9 +1434,11 @@ xfs_ioctl_setattr_check_projid(
14281434
14291435STATIC int
14301436xfs_ioctl_setattr (
1431- xfs_inode_t * ip ,
1437+ struct file * file ,
14321438 struct fsxattr * fa )
14331439{
1440+ struct user_namespace * mnt_userns = file_mnt_user_ns (file );
1441+ struct xfs_inode * ip = XFS_I (file_inode (file ));
14341442 struct fsxattr old_fa ;
14351443 struct xfs_mount * mp = ip -> i_mount ;
14361444 struct xfs_trans * tp ;
@@ -1462,7 +1470,7 @@ xfs_ioctl_setattr(
14621470
14631471 xfs_ioctl_setattr_prepare_dax (ip , fa );
14641472
1465- tp = xfs_ioctl_setattr_get_trans (ip );
1473+ tp = xfs_ioctl_setattr_get_trans (file );
14661474 if (IS_ERR (tp )) {
14671475 code = PTR_ERR (tp );
14681476 goto error_free_dquots ;
@@ -1502,7 +1510,7 @@ xfs_ioctl_setattr(
15021510 */
15031511
15041512 if ((VFS_I (ip )-> i_mode & (S_ISUID |S_ISGID )) &&
1505- !capable_wrt_inode_uidgid (& init_user_ns , VFS_I (ip ), CAP_FSETID ))
1513+ !capable_wrt_inode_uidgid (mnt_userns , VFS_I (ip ), CAP_FSETID ))
15061514 VFS_I (ip )-> i_mode &= ~(S_ISUID |S_ISGID );
15071515
15081516 /* Change the ownerships and register project quota modifications */
@@ -1549,7 +1557,6 @@ xfs_ioctl_setattr(
15491557
15501558STATIC int
15511559xfs_ioc_fssetxattr (
1552- xfs_inode_t * ip ,
15531560 struct file * filp ,
15541561 void __user * arg )
15551562{
@@ -1562,7 +1569,7 @@ xfs_ioc_fssetxattr(
15621569 error = mnt_want_write_file (filp );
15631570 if (error )
15641571 return error ;
1565- error = xfs_ioctl_setattr (ip , & fa );
1572+ error = xfs_ioctl_setattr (filp , & fa );
15661573 mnt_drop_write_file (filp );
15671574 return error ;
15681575}
@@ -1608,7 +1615,7 @@ xfs_ioc_setxflags(
16081615
16091616 xfs_ioctl_setattr_prepare_dax (ip , & fa );
16101617
1611- tp = xfs_ioctl_setattr_get_trans (ip );
1618+ tp = xfs_ioctl_setattr_get_trans (filp );
16121619 if (IS_ERR (tp )) {
16131620 error = PTR_ERR (tp );
16141621 goto out_drop_write ;
@@ -2119,10 +2126,10 @@ xfs_file_ioctl(
21192126 case XFS_IOC_FSBULKSTAT_SINGLE :
21202127 case XFS_IOC_FSBULKSTAT :
21212128 case XFS_IOC_FSINUMBERS :
2122- return xfs_ioc_fsbulkstat (mp , cmd , arg );
2129+ return xfs_ioc_fsbulkstat (filp , cmd , arg );
21232130
21242131 case XFS_IOC_BULKSTAT :
2125- return xfs_ioc_bulkstat (mp , cmd , arg );
2132+ return xfs_ioc_bulkstat (filp , cmd , arg );
21262133 case XFS_IOC_INUMBERS :
21272134 return xfs_ioc_inumbers (mp , cmd , arg );
21282135
@@ -2144,7 +2151,7 @@ xfs_file_ioctl(
21442151 case XFS_IOC_FSGETXATTRA :
21452152 return xfs_ioc_fsgetxattr (ip , 1 , arg );
21462153 case XFS_IOC_FSSETXATTR :
2147- return xfs_ioc_fssetxattr (ip , filp , arg );
2154+ return xfs_ioc_fssetxattr (filp , arg );
21482155 case XFS_IOC_GETXFLAGS :
21492156 return xfs_ioc_getxflags (ip , arg );
21502157 case XFS_IOC_SETXFLAGS :
0 commit comments