userns: Convert isofs to use kuid/kgid where appropriate
[firefly-linux-kernel-4.4.55.git] / fs / isofs / inode.c
index bd62c76fb5df8a08d8d11bdae311ecc8a3054039..a7d8e6cc5e0c140cb29253c1d9433215584c6ccf 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/cdrom.h>
 #include <linux/parser.h>
 #include <linux/mpage.h>
+#include <linux/user_namespace.h>
 
 #include "isofs.h"
 #include "zisofs.h"
@@ -171,8 +172,8 @@ struct iso9660_options{
        unsigned int blocksize;
        umode_t fmode;
        umode_t dmode;
-       gid_t gid;
-       uid_t uid;
+       kgid_t gid;
+       kuid_t uid;
        char *iocharset;
        /* LVE */
        s32 session;
@@ -383,8 +384,8 @@ static int parse_options(char *options, struct iso9660_options *popt)
        popt->fmode = popt->dmode = ISOFS_INVALID_MODE;
        popt->uid_set = 0;
        popt->gid_set = 0;
-       popt->gid = 0;
-       popt->uid = 0;
+       popt->gid = GLOBAL_ROOT_GID;
+       popt->uid = GLOBAL_ROOT_UID;
        popt->iocharset = NULL;
        popt->utf8 = 0;
        popt->overriderockperm = 0;
@@ -460,13 +461,17 @@ static int parse_options(char *options, struct iso9660_options *popt)
                case Opt_uid:
                        if (match_int(&args[0], &option))
                                return 0;
-                       popt->uid = option;
+                       popt->uid = make_kuid(current_user_ns(), option);
+                       if (!uid_valid(popt->uid))
+                               return 0;
                        popt->uid_set = 1;
                        break;
                case Opt_gid:
                        if (match_int(&args[0], &option))
                                return 0;
-                       popt->gid = option;
+                       popt->gid = make_kgid(current_user_ns(), option);
+                       if (!gid_valid(popt->gid))
+                               return 0;
                        popt->gid_set = 1;
                        break;
                case Opt_mode:
@@ -947,9 +952,8 @@ root_found:
        s->s_d_op = &isofs_dentry_ops[table];
 
        /* get the root dentry */
-       s->s_root = d_alloc_root(inode);
+       s->s_root = d_make_root(inode);
        if (!(s->s_root)) {
-               iput(inode);
                error = -ENOMEM;
                goto out_no_inode;
        }