@@ -1448,6 +1448,8 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
14481448{
14491449 struct ext4_sb_info * sbi = EXT4_SB (sb );
14501450 const struct mount_opts * m ;
1451+ kuid_t uid ;
1452+ kgid_t gid ;
14511453 int arg = 0 ;
14521454
14531455 if (args -> from && match_int (args , & arg ))
@@ -1464,10 +1466,20 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
14641466 "Ignoring removed %s option" , opt );
14651467 return 1 ;
14661468 case Opt_resuid :
1467- sbi -> s_resuid = arg ;
1469+ uid = make_kuid (current_user_ns (), arg );
1470+ if (!uid_valid (uid )) {
1471+ ext4_msg (sb , KERN_ERR , "Invalid uid value %d" , arg );
1472+ return -1 ;
1473+ }
1474+ sbi -> s_resuid = uid ;
14681475 return 1 ;
14691476 case Opt_resgid :
1470- sbi -> s_resgid = arg ;
1477+ gid = make_kgid (current_user_ns (), arg );
1478+ if (!gid_valid (gid )) {
1479+ ext4_msg (sb , KERN_ERR , "Invalid gid value %d" , arg );
1480+ return -1 ;
1481+ }
1482+ sbi -> s_resgid = gid ;
14711483 return 1 ;
14721484 case Opt_abort :
14731485 sbi -> s_mount_flags |= EXT4_MF_FS_ABORTED ;
@@ -1732,12 +1744,14 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb,
17321744 SEQ_OPTS_PRINT ("%s" , token2str (m -> token ));
17331745 }
17341746
1735- if (nodefs || sbi -> s_resuid != EXT4_DEF_RESUID ||
1747+ if (nodefs || ! uid_eq ( sbi -> s_resuid , make_kuid ( & init_user_ns , EXT4_DEF_RESUID )) ||
17361748 le16_to_cpu (es -> s_def_resuid ) != EXT4_DEF_RESUID )
1737- SEQ_OPTS_PRINT ("resuid=%u" , sbi -> s_resuid );
1738- if (nodefs || sbi -> s_resgid != EXT4_DEF_RESGID ||
1749+ SEQ_OPTS_PRINT ("resuid=%u" ,
1750+ from_kuid_munged (& init_user_ns , sbi -> s_resuid ));
1751+ if (nodefs || !gid_eq (sbi -> s_resgid , make_kgid (& init_user_ns , EXT4_DEF_RESGID )) ||
17391752 le16_to_cpu (es -> s_def_resgid ) != EXT4_DEF_RESGID )
1740- SEQ_OPTS_PRINT ("resgid=%u" , sbi -> s_resgid );
1753+ SEQ_OPTS_PRINT ("resgid=%u" ,
1754+ from_kgid_munged (& init_user_ns , sbi -> s_resgid ));
17411755 def_errors = nodefs ? -1 : le16_to_cpu (es -> s_errors );
17421756 if (test_opt (sb , ERRORS_RO ) && def_errors != EXT4_ERRORS_RO )
17431757 SEQ_OPTS_PUTS ("errors=remount-ro" );
@@ -2996,8 +3010,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
29963010 }
29973011 sb -> s_fs_info = sbi ;
29983012 sbi -> s_mount_opt = 0 ;
2999- sbi -> s_resuid = EXT4_DEF_RESUID ;
3000- sbi -> s_resgid = EXT4_DEF_RESGID ;
3013+ sbi -> s_resuid = make_kuid ( & init_user_ns , EXT4_DEF_RESUID ) ;
3014+ sbi -> s_resgid = make_kgid ( & init_user_ns , EXT4_DEF_RESGID ) ;
30013015 sbi -> s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS ;
30023016 sbi -> s_sb_block = sb_block ;
30033017 if (sb -> s_bdev -> bd_part )
@@ -3076,8 +3090,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
30763090 if (def_mount_opts & EXT4_DEFM_DISCARD )
30773091 set_opt (sb , DISCARD );
30783092
3079- sbi -> s_resuid = le16_to_cpu (es -> s_def_resuid );
3080- sbi -> s_resgid = le16_to_cpu (es -> s_def_resgid );
3093+ sbi -> s_resuid = make_kuid ( & init_user_ns , le16_to_cpu (es -> s_def_resuid ) );
3094+ sbi -> s_resgid = make_kgid ( & init_user_ns , le16_to_cpu (es -> s_def_resgid ) );
30813095 sbi -> s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ ;
30823096 sbi -> s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME ;
30833097 sbi -> s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME ;
@@ -4229,8 +4243,8 @@ static int ext4_unfreeze(struct super_block *sb)
42294243struct ext4_mount_options {
42304244 unsigned long s_mount_opt ;
42314245 unsigned long s_mount_opt2 ;
4232- uid_t s_resuid ;
4233- gid_t s_resgid ;
4246+ kuid_t s_resuid ;
4247+ kgid_t s_resgid ;
42344248 unsigned long s_commit_interval ;
42354249 u32 s_min_batch_time , s_max_batch_time ;
42364250#ifdef CONFIG_QUOTA
0 commit comments