userns: Convert the udf filesystem to use kuid/kgid where appropriate
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 10 Feb 2012 20:20:35 +0000 (12:20 -0800)
committerEric W. Biederman <ebiederm@xmission.com>
Fri, 21 Sep 2012 11:18:54 +0000 (04:18 -0700)
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
fs/udf/inode.c
fs/udf/super.c
fs/udf/udf_sb.h
init/Kconfig

index fafaad795cd6da4842a798e25446f6b426d65d65..1825dc0af728ec2abcc166ef4c7c0a30b699e9f2 100644 (file)
@@ -1309,14 +1309,14 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
        }
 
        read_lock(&sbi->s_cred_lock);
-       inode->i_uid = le32_to_cpu(fe->uid);
-       if (inode->i_uid == -1 ||
+       i_uid_write(inode, le32_to_cpu(fe->uid));
+       if (!uid_valid(inode->i_uid) ||
            UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_IGNORE) ||
            UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_SET))
                inode->i_uid = UDF_SB(inode->i_sb)->s_uid;
 
-       inode->i_gid = le32_to_cpu(fe->gid);
-       if (inode->i_gid == -1 ||
+       i_gid_write(inode, le32_to_cpu(fe->gid));
+       if (!gid_valid(inode->i_gid) ||
            UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_IGNORE) ||
            UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_SET))
                inode->i_gid = UDF_SB(inode->i_sb)->s_gid;
@@ -1539,12 +1539,12 @@ static int udf_update_inode(struct inode *inode, int do_sync)
        if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET))
                fe->uid = cpu_to_le32(-1);
        else
-               fe->uid = cpu_to_le32(inode->i_uid);
+               fe->uid = cpu_to_le32(i_uid_read(inode));
 
        if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET))
                fe->gid = cpu_to_le32(-1);
        else
-               fe->gid = cpu_to_le32(inode->i_gid);
+               fe->gid = cpu_to_le32(i_gid_read(inode));
 
        udfperms = ((inode->i_mode & S_IRWXO)) |
                   ((inode->i_mode & S_IRWXG) << 2) |
index dcbf98722afcd5df2a8940f4dbd5c1c8a02c7b40..38c705574b9239610119689d53aab87069c1ecad 100644 (file)
@@ -199,8 +199,8 @@ struct udf_options {
        unsigned int rootdir;
        unsigned int flags;
        umode_t umask;
-       gid_t gid;
-       uid_t uid;
+       kgid_t gid;
+       kuid_t uid;
        umode_t fmode;
        umode_t dmode;
        struct nls_table *nls_map;
@@ -335,9 +335,9 @@ static int udf_show_options(struct seq_file *seq, struct dentry *root)
        if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_IGNORE))
                seq_puts(seq, ",gid=ignore");
        if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET))
-               seq_printf(seq, ",uid=%u", sbi->s_uid);
+               seq_printf(seq, ",uid=%u", from_kuid(&init_user_ns, sbi->s_uid));
        if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET))
-               seq_printf(seq, ",gid=%u", sbi->s_gid);
+               seq_printf(seq, ",gid=%u", from_kgid(&init_user_ns, sbi->s_gid));
        if (sbi->s_umask != 0)
                seq_printf(seq, ",umask=%ho", sbi->s_umask);
        if (sbi->s_fmode != UDF_INVALID_MODE)
@@ -516,13 +516,17 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
                case Opt_gid:
                        if (match_int(args, &option))
                                return 0;
-                       uopt->gid = option;
+                       uopt->gid = make_kgid(current_user_ns(), option);
+                       if (!gid_valid(uopt->gid))
+                               return 0;
                        uopt->flags |= (1 << UDF_FLAG_GID_SET);
                        break;
                case Opt_uid:
                        if (match_int(args, &option))
                                return 0;
-                       uopt->uid = option;
+                       uopt->uid = make_kuid(current_user_ns(), option);
+                       if (!uid_valid(uopt->uid))
+                               return 0;
                        uopt->flags |= (1 << UDF_FLAG_UID_SET);
                        break;
                case Opt_umask:
@@ -1931,8 +1935,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
        struct udf_sb_info *sbi;
 
        uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT);
-       uopt.uid = -1;
-       uopt.gid = -1;
+       uopt.uid = INVALID_UID;
+       uopt.gid = INVALID_GID;
        uopt.umask = 0;
        uopt.fmode = UDF_INVALID_MODE;
        uopt.dmode = UDF_INVALID_MODE;
index 42ad69ac95769cf7e14bc0228f5a4ec67f77b9e3..5f027227f085464d33b2434a1cad64a44195c54d 100644 (file)
@@ -128,8 +128,8 @@ struct udf_sb_info {
 
        /* Default permissions */
        umode_t                 s_umask;
-       gid_t                   s_gid;
-       uid_t                   s_uid;
+       kgid_t                  s_gid;
+       kuid_t                  s_uid;
        umode_t                 s_fmode;
        umode_t                 s_dmode;
        /* Lock protecting consistency of above permission settings */
index 21adc1c997adcfc267b7b1ba67ff41b845467d0e..6f9819ac322bc5208cbbb93cff32f859f8bf2d89 100644 (file)
@@ -939,7 +939,6 @@ config UIDGID_CONVERTED
        depends on NFSD = n
        depends on NFS_FS = n
        depends on OCFS2_FS = n
-       depends on UDF_FS = n
        depends on UFS_FS = n
        depends on XFS_FS = n