staging/lustre: fix build when CONFIG_UIDGID_STRICT_TYPE_CHECKS is on
authorPeng Tao <bergwolf@gmail.com>
Mon, 15 Jul 2013 14:27:14 +0000 (22:27 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Jul 2013 19:24:04 +0000 (12:24 -0700)
kuid_t/kgid_t are wrappered when CONFIG_UIDGID_STRICT_TYPE_CHECKS is on.
Lustre build is broken because we always treat them as plain __u32.
The patch fixes it. Internally, Lustre always use __u32 uid/gid, and
convert to kuid_t/kgid_t when necessary.

Signed-off-by: Peng Tao <tao.peng@emc.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 files changed:
drivers/staging/lustre/include/linux/libcfs/curproc.h
drivers/staging/lustre/lustre/include/linux/lvfs.h
drivers/staging/lustre/lustre/include/lustre_cfg.h
drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c
drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
drivers/staging/lustre/lustre/llite/dir.c
drivers/staging/lustre/lustre/llite/llite_lib.c
drivers/staging/lustre/lustre/llite/lproc_llite.c
drivers/staging/lustre/lustre/llite/namei.c
drivers/staging/lustre/lustre/llite/remote_perm.c
drivers/staging/lustre/lustre/llite/vvp_object.c
drivers/staging/lustre/lustre/lmv/lmv_obd.c
drivers/staging/lustre/lustre/mdc/mdc_lib.c
drivers/staging/lustre/lustre/mdc/mdc_request.c
drivers/staging/lustre/lustre/obdclass/class_obd.c
drivers/staging/lustre/lustre/obdclass/idmap.c
drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c
drivers/staging/lustre/lustre/obdclass/obdo.c
drivers/staging/lustre/lustre/obdecho/echo_client.c
drivers/staging/lustre/lustre/ptlrpc/sec.c

index 90d7ce630e94cfa39ba816954e682c608e998544..de8e35b796ab475b9bbe79f3ba91c2ec3ba41d4f 100644 (file)
@@ -49,8 +49,6 @@
  * Implemented in portals/include/libcfs/<os>/
  */
 int    cfs_curproc_groups_nr(void);
-int    current_is_in_group(gid_t group);
-void   cfs_curproc_groups_dump(gid_t *array, int size);
 
 /*
  * Plus, platform-specific constant
index eb59ac7d5946b3dda15b3f909ad88833c2ccbbfd..e61f1b87f822c29825fff5190b1fb5be87838858 100644 (file)
 /* simple.c */
 
 struct lvfs_ucred {
-       __u32              luc_uid;
-       __u32              luc_gid;
-       __u32              luc_fsuid;
-       __u32              luc_fsgid;
+       kuid_t          luc_uid;
+       kgid_t          luc_gid;
+       kuid_t          luc_fsuid;
+       kgid_t          luc_fsgid;
        kernel_cap_t    luc_cap;
        __u32              luc_umask;
        struct group_info      *luc_ginfo;
index f12429f382159732a9cf7d0fc4bd504950dadf89..fbf94a081ffd424c006a6c87b9253e30d717a8d0 100644 (file)
@@ -290,10 +290,6 @@ static inline int lustre_cfg_sanity_check(void *buf, int len)
 
 #include <lustre/lustre_user.h>
 
-#ifndef INVALID_UID
-#define INVALID_UID     (-1)
-#endif
-
 /** @} cfg */
 
 #endif // _LUSTRE_CFG_H
index f236510a2f3fdfb0904cb1cb561d2632f82a1fed..706dfb39fc2871c814fa12adf152ef9068f97084 100644 (file)
@@ -65,20 +65,6 @@ int    cfs_curproc_groups_nr(void)
        return nr;
 }
 
-void   cfs_curproc_groups_dump(gid_t *array, int size)
-{
-       task_lock(current);
-       size = min_t(int, size, current_cred()->group_info->ngroups);
-       memcpy(array, current_cred()->group_info->blocks[0], size * sizeof(__u32));
-       task_unlock(current);
-}
-
-
-int    current_is_in_group(gid_t gid)
-{
-       return in_group_p(gid);
-}
-
 /* Currently all the CFS_CAP_* defines match CAP_* ones. */
 #define cfs_cap_pack(cap) (cap)
 #define cfs_cap_unpack(cap) (cap)
@@ -318,8 +304,6 @@ out:
 EXPORT_SYMBOL(cfs_get_environ);
 
 EXPORT_SYMBOL(cfs_curproc_groups_nr);
-EXPORT_SYMBOL(cfs_curproc_groups_dump);
-EXPORT_SYMBOL(current_is_in_group);
 EXPORT_SYMBOL(cfs_cap_raise);
 EXPORT_SYMBOL(cfs_cap_lower);
 EXPORT_SYMBOL(cfs_cap_raised);
index 2c7d4a3d660fe3da0abef8cb44c68e7482fbfca3..6b0054ff79159cab1c4863145d8dedda0dd1939a 100644 (file)
@@ -137,7 +137,7 @@ static long libcfs_ioctl(struct file *file,
        struct cfs_psdev_file    pfile;
        int    rc = 0;
 
-       if (current_fsuid() != 0)
+       if (!capable(CAP_SYS_ADMIN))
                return -EACCES;
 
        if ( _IOC_TYPE(cmd) != IOC_LIBCFS_TYPE ||
index 13a6426bdd9fc586b5f2bb4f2fb5e0a449d8c68c..e2afb97303434f913b3001b2e76a25c9f5dfdae0 100644 (file)
@@ -685,7 +685,8 @@ int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump,
 
        op_data->op_cli_flags |= CLI_SET_MEA;
        err = md_create(sbi->ll_md_exp, op_data, lump, sizeof(*lump), mode,
-                       current_fsuid(), current_fsgid(),
+                       from_kuid(&init_user_ns, current_fsuid()),
+                       from_kgid(&init_user_ns, current_fsgid()),
                        cfs_curproc_cap_pack(), 0, &request);
        ll_finish_md_op_data(op_data);
        if (err)
@@ -1105,8 +1106,10 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
                        RETURN(-EPERM);
                break;
        case Q_GETQUOTA:
-               if (((type == USRQUOTA && current_euid() != id) ||
-                    (type == GRPQUOTA && !in_egroup_p(id))) &&
+               if (((type == USRQUOTA &&
+                     uid_eq(current_euid(), make_kuid(&init_user_ns, id))) ||
+                    (type == GRPQUOTA &&
+                     !in_egroup_p(make_kgid(&init_user_ns, id)))) &&
                    (!cfs_capable(CFS_CAP_SYS_ADMIN) ||
                     sbi->ll_flags & LL_SBI_RMT_CLIENT))
                        RETURN(-EPERM);
index afae8010623d5ddbd90e21aac9ecb9a22453e58e..1eb5779c1bdadd892ebcc8aff7feb76221748568 100644 (file)
@@ -1400,7 +1400,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr)
 
        /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
        if (attr->ia_valid & TIMES_SET_FLAGS) {
-               if (current_fsuid() != inode->i_uid &&
+               if ((!uid_eq(current_fsuid(), inode->i_uid)) &&
                    !cfs_capable(CFS_CAP_FOWNER))
                        RETURN(-EPERM);
        }
@@ -1707,9 +1707,9 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
                inode->i_blkbits = inode->i_sb->s_blocksize_bits;
        }
        if (body->valid & OBD_MD_FLUID)
-               inode->i_uid = body->uid;
+               inode->i_uid = make_kuid(&init_user_ns, body->uid);
        if (body->valid & OBD_MD_FLGID)
-               inode->i_gid = body->gid;
+               inode->i_gid = make_kgid(&init_user_ns, body->gid);
        if (body->valid & OBD_MD_FLFLAGS)
                inode->i_flags = ll_ext_to_inode_flags(body->flags);
        if (body->valid & OBD_MD_FLNLINK)
@@ -1959,7 +1959,8 @@ int ll_flush_ctx(struct inode *inode)
 {
        struct ll_sb_info  *sbi = ll_i2sbi(inode);
 
-       CDEBUG(D_SEC, "flush context for user %d\n", current_uid());
+       CDEBUG(D_SEC, "flush context for user %d\n",
+                     from_kuid(&init_user_ns, current_uid()));
 
        obd_set_info_async(NULL, sbi->ll_md_exp,
                           sizeof(KEY_FLUSH_CTX), KEY_FLUSH_CTX,
@@ -2238,8 +2239,8 @@ struct md_op_data * ll_prep_md_op_data(struct md_op_data *op_data,
        op_data->op_namelen = namelen;
        op_data->op_mode = mode;
        op_data->op_mod_time = cfs_time_current_sec();
-       op_data->op_fsuid = current_fsuid();
-       op_data->op_fsgid = current_fsgid();
+       op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
+       op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
        op_data->op_cap = cfs_curproc_cap_pack();
        op_data->op_bias = 0;
        op_data->op_cli_flags = 0;
index a30c411b583bc1767c65eab47c33fa4edb3ef271..5c7368c358a0f1aa434ad6d7e272f7d80d9c7bc8 100644 (file)
@@ -822,7 +822,8 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count)
                 sbi->ll_stats_track_id == current->parent->pid)
                lprocfs_counter_add(sbi->ll_stats, op, count);
        else if (sbi->ll_stats_track_type == STATS_TRACK_GID &&
-                sbi->ll_stats_track_id == current_gid())
+                sbi->ll_stats_track_id ==
+                       from_kgid(&init_user_ns, current_gid()))
                lprocfs_counter_add(sbi->ll_stats, op, count);
 }
 EXPORT_SYMBOL(ll_stats_ops_tally);
index ff8f63de5612a03f7baae80efcb252ab865719ce..8e948a71dd644e67ecc536a25f65cd2cf5295280 100644 (file)
@@ -302,8 +302,8 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
 
 __u32 ll_i2suppgid(struct inode *i)
 {
-       if (current_is_in_group(i->i_gid))
-               return (__u32)i->i_gid;
+       if (in_group_p(i->i_gid))
+               return (__u32)from_kgid(&init_user_ns, i->i_gid);
        else
                return (__u32)(-1);
 }
@@ -805,7 +805,8 @@ static int ll_new_node(struct inode *dir, struct qstr *name,
                GOTO(err_exit, err = PTR_ERR(op_data));
 
        err = md_create(sbi->ll_md_exp, op_data, tgt, tgt_len, mode,
-                       current_fsuid(), current_fsgid(),
+                       from_kuid(&init_user_ns, current_fsuid()),
+                       from_kgid(&init_user_ns, current_fsgid()),
                        cfs_curproc_cap_pack(), rdev, &request);
        ll_finish_md_op_data(op_data);
        if (err)
index 68b2dc4a7b62ac652c4b5c73c7205e31d8cb6e72..4f176e16e01c7731cfb7727aa474369f92a7339b 100644 (file)
@@ -129,17 +129,18 @@ static int do_check_remote_perm(struct ll_inode_info *lli, int mask)
        if (!lli->lli_remote_perms)
                RETURN(-ENOENT);
 
-       head = lli->lli_remote_perms + remote_perm_hashfunc(current_uid());
+       head = lli->lli_remote_perms +
+               remote_perm_hashfunc(from_kuid(&init_user_ns, current_uid()));
 
        spin_lock(&lli->lli_lock);
        hlist_for_each_entry(lrp, head, lrp_list) {
-               if (lrp->lrp_uid != current_uid())
+               if (lrp->lrp_uid != from_kuid(&init_user_ns, current_uid()))
                        continue;
-               if (lrp->lrp_gid != current_gid())
+               if (lrp->lrp_gid != from_kgid(&init_user_ns, current_gid()))
                        continue;
-               if (lrp->lrp_fsuid != current_fsuid())
+               if (lrp->lrp_fsuid != from_kuid(&init_user_ns, current_fsuid()))
                        continue;
-               if (lrp->lrp_fsgid != current_fsgid())
+               if (lrp->lrp_fsgid != from_kgid(&init_user_ns, current_fsgid()))
                        continue;
                found = 1;
                break;
index 01edc5b63e13e3c225b6ea37b27d60e15fc90ec6..33173fce478fdc658b95db3c41211b4adeb16ec5 100644 (file)
@@ -91,8 +91,8 @@ static int vvp_attr_get(const struct lu_env *env, struct cl_object *obj,
        attr->cat_atime = LTIME_S(inode->i_atime);
        attr->cat_ctime = LTIME_S(inode->i_ctime);
        attr->cat_blocks = inode->i_blocks;
-       attr->cat_uid = inode->i_uid;
-       attr->cat_gid = inode->i_gid;
+       attr->cat_uid = from_kuid(&init_user_ns, inode->i_uid);
+       attr->cat_gid = from_kgid(&init_user_ns, inode->i_gid);
        /* KMS is not known by this layer */
        return 0; /* layers below have to fill in the rest */
 }
@@ -103,9 +103,9 @@ static int vvp_attr_set(const struct lu_env *env, struct cl_object *obj,
        struct inode *inode = ccc_object_inode(obj);
 
        if (valid & CAT_UID)
-               inode->i_uid = attr->cat_uid;
+               inode->i_uid = make_kuid(&init_user_ns, attr->cat_uid);
        if (valid & CAT_GID)
-               inode->i_gid = attr->cat_gid;
+               inode->i_gid = make_kgid(&init_user_ns, attr->cat_gid);
        if (valid & CAT_ATIME)
                LTIME_S(inode->i_atime) = attr->cat_atime;
        if (valid & CAT_MTIME)
index 1eebfbf34871fa9a24ae0d543d00843d8f4323c9..d10f7fc553d3be5f9ce69894aa85c90e7e2fe709 100644 (file)
@@ -1757,8 +1757,8 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data,
               PFID(&op_data->op_fid2), op_data->op_namelen,
               op_data->op_name, PFID(&op_data->op_fid1));
 
-       op_data->op_fsuid = current_fsuid();
-       op_data->op_fsgid = current_fsgid();
+       op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
+       op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
        op_data->op_cap = cfs_curproc_cap_pack();
        tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2);
        if (IS_ERR(tgt))
@@ -1799,8 +1799,8 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
        if (rc)
                RETURN(rc);
 
-       op_data->op_fsuid = current_fsuid();
-       op_data->op_fsgid = current_fsgid();
+       op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
+       op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
        op_data->op_cap = cfs_curproc_cap_pack();
        src_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
        if (IS_ERR(src_tgt))
@@ -2061,8 +2061,8 @@ retry:
        if (IS_ERR(tgt))
                RETURN(PTR_ERR(tgt));
 
-       op_data->op_fsuid = current_fsuid();
-       op_data->op_fsgid = current_fsgid();
+       op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
+       op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
        op_data->op_cap = cfs_curproc_cap_pack();
 
        /*
index e789aed98de06971e363dc74c1ae80905cbfefa1..2e5c7cef61ce293cad6bd1aa8bbbf78263783595 100644 (file)
@@ -45,10 +45,10 @@ static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid)
        LASSERT (b != NULL);
 
        b->suppgid = suppgid;
-       b->uid = current_uid();
-       b->gid = current_gid();
-       b->fsuid = current_fsuid();
-       b->fsgid = current_fsgid();
+       b->uid = from_kuid(&init_user_ns, current_uid());
+       b->gid = from_kgid(&init_user_ns, current_gid());
+       b->fsuid = from_kuid(&init_user_ns, current_fsuid());
+       b->fsgid = from_kgid(&init_user_ns, current_fsgid());
        b->capability = cfs_curproc_cap_pack();
 }
 
@@ -219,8 +219,8 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
 
        /* XXX do something about time, uid, gid */
        rec->cr_opcode   = REINT_OPEN;
-       rec->cr_fsuid   = current_fsuid();
-       rec->cr_fsgid   = current_fsgid();
+       rec->cr_fsuid    = from_kuid(&init_user_ns, current_fsuid());
+       rec->cr_fsgid    = from_kgid(&init_user_ns, current_fsgid());
        rec->cr_cap      = cfs_curproc_cap_pack();
        if (op_data != NULL) {
                rec->cr_fid1 = op_data->op_fid1;
@@ -299,16 +299,16 @@ static void mdc_setattr_pack_rec(struct mdt_rec_setattr *rec,
                                 struct md_op_data *op_data)
 {
        rec->sa_opcode  = REINT_SETATTR;
-       rec->sa_fsuid   = current_fsuid();
-       rec->sa_fsgid   = current_fsgid();
+       rec->sa_fsuid   = from_kuid(&init_user_ns, current_fsuid());
+       rec->sa_fsgid   = from_kgid(&init_user_ns, current_fsgid());
        rec->sa_cap     = cfs_curproc_cap_pack();
        rec->sa_suppgid = -1;
 
        rec->sa_fid    = op_data->op_fid1;
        rec->sa_valid  = attr_pack(op_data->op_attr.ia_valid);
        rec->sa_mode   = op_data->op_attr.ia_mode;
-       rec->sa_uid    = op_data->op_attr.ia_uid;
-       rec->sa_gid    = op_data->op_attr.ia_gid;
+       rec->sa_uid    = from_kuid(&init_user_ns, op_data->op_attr.ia_uid);
+       rec->sa_gid    = from_kgid(&init_user_ns, op_data->op_attr.ia_gid);
        rec->sa_size   = op_data->op_attr.ia_size;
        rec->sa_blocks = op_data->op_attr_blocks;
        rec->sa_atime  = LTIME_S(op_data->op_attr.ia_atime);
@@ -316,8 +316,9 @@ static void mdc_setattr_pack_rec(struct mdt_rec_setattr *rec,
        rec->sa_ctime  = LTIME_S(op_data->op_attr.ia_ctime);
        rec->sa_attr_flags = ((struct ll_iattr *)&op_data->op_attr)->ia_attr_flags;
        if ((op_data->op_attr.ia_valid & ATTR_GID) &&
-           current_is_in_group(op_data->op_attr.ia_gid))
-               rec->sa_suppgid = op_data->op_attr.ia_gid;
+           in_group_p(op_data->op_attr.ia_gid))
+               rec->sa_suppgid =
+                       from_kgid(&init_user_ns, op_data->op_attr.ia_gid);
        else
                rec->sa_suppgid = op_data->op_suppgids[0];
 
index 3cf9d8d3f2ec13d2f4160f21feecfacfca311681..21e8a9d161301a24758b1f6f50dbeff6b0a3129d 100644 (file)
@@ -377,12 +377,8 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt,
                         sizeof(struct mdt_rec_reint));
                rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
                rec->sx_opcode = REINT_SETXATTR;
-               /* TODO:
-                *  cfs_curproc_fs{u,g}id() should replace
-                *  current->fs{u,g}id for portability.
-                */
-               rec->sx_fsuid  = current_fsuid();
-               rec->sx_fsgid  = current_fsgid();
+               rec->sx_fsuid  = from_kuid(&init_user_ns, current_fsuid());
+               rec->sx_fsgid  = from_kgid(&init_user_ns, current_fsgid());
                rec->sx_cap    = cfs_curproc_cap_pack();
                rec->sx_suppgid1 = suppgid;
                rec->sx_suppgid2 = -1;
index 0715cf2af3ce54f899da5837eb291d88a0a9dc69..799a1ed8701f36d502520c557bd14c3b773cc562 100644 (file)
@@ -122,7 +122,8 @@ int lustre_get_jobid(char *jobid)
        /* Use process name + fsuid as jobid */
        if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) {
                snprintf(jobid, JOBSTATS_JOBID_SIZE, "%s.%u",
-                        current_comm(), current_fsuid());
+                        current_comm(),
+                        from_kuid(&init_user_ns, current_fsuid()));
                RETURN(0);
        }
 
index 622f8d16527597edc69ef9655f36f756a95466a4..afb66a49f828504a96a9ccc8bfb464641c095040 100644 (file)
@@ -71,7 +71,8 @@ static int lustre_groups_search(group_info_t *group_info,
        right = group_info->ngroups;
        while (left < right) {
                int mid = (left + right) / 2;
-               int cmp = grp - CFS_GROUP_AT(group_info, mid);
+               int cmp = grp -
+                       from_kgid(&init_user_ns, CFS_GROUP_AT(group_info, mid));
 
                if (cmp > 0)
                        left = mid + 1;
@@ -116,16 +117,19 @@ void lustre_groups_sort(group_info_t *group_info)
                for (base = 0; base < max; base++) {
                        int left = base;
                        int right = left + stride;
-                       gid_t tmp = CFS_GROUP_AT(group_info, right);
+                       gid_t tmp = from_kgid(&init_user_ns,
+                                             CFS_GROUP_AT(group_info, right));
 
                        while (left >= 0 &&
-                              CFS_GROUP_AT(group_info, left) > tmp) {
+                              tmp < from_kgid(&init_user_ns,
+                                              CFS_GROUP_AT(group_info, left))) {
                                CFS_GROUP_AT(group_info, right) =
                                    CFS_GROUP_AT(group_info, left);
                                right = left;
                                left -= stride;
                        }
-                       CFS_GROUP_AT(group_info, right) = tmp;
+                       CFS_GROUP_AT(group_info, right) =
+                                               make_kgid(&init_user_ns, tmp);
                }
                stride /= 3;
        }
index 6ee347153a16795d9c03fecf2f2d8d962d896e0e..d3bb5ffc564b1d782c527ed8f4c8e0a0779bfd1f 100644 (file)
@@ -213,9 +213,9 @@ void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid)
        if (valid & OBD_MD_FLMODE)
                dst->i_mode = (dst->i_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
        if (valid & OBD_MD_FLUID)
-               dst->i_uid = src->o_uid;
+               dst->i_uid = make_kuid(&init_user_ns, src->o_uid);
        if (valid & OBD_MD_FLGID)
-               dst->i_gid = src->o_gid;
+               dst->i_gid = make_kgid(&init_user_ns, src->o_gid);
        if (valid & OBD_MD_FLFLAGS)
                dst->i_flags = src->o_flags;
 }
index 01a0e1f83a684a3cad04e71dd10d7b9149063445..70997648a4f3c935bf160d13fe3ba8eaa8676f5b 100644 (file)
@@ -100,11 +100,11 @@ void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid)
                newvalid |= OBD_MD_FLMODE;
        }
        if (valid & OBD_MD_FLUID) {
-               dst->o_uid = src->i_uid;
+               dst->o_uid = from_kuid(&init_user_ns, src->i_uid);
                newvalid |= OBD_MD_FLUID;
        }
        if (valid & OBD_MD_FLGID) {
-               dst->o_gid = src->i_gid;
+               dst->o_gid = from_kgid(&init_user_ns, src->i_gid);
                newvalid |= OBD_MD_FLGID;
        }
        if (valid & OBD_MD_FLFLAGS) {
@@ -232,16 +232,16 @@ void obdo_from_iattr(struct obdo *oa, struct iattr *attr, unsigned int ia_valid)
        if (ia_valid & ATTR_MODE) {
                oa->o_mode = attr->ia_mode;
                oa->o_valid |= OBD_MD_FLTYPE | OBD_MD_FLMODE;
-               if (!current_is_in_group(oa->o_gid) &&
+               if (!in_group_p(make_kgid(&init_user_ns, oa->o_gid)) &&
                    !cfs_capable(CFS_CAP_FSETID))
                        oa->o_mode &= ~S_ISGID;
        }
        if (ia_valid & ATTR_UID) {
-               oa->o_uid = attr->ia_uid;
+               oa->o_uid = from_kuid(&init_user_ns, attr->ia_uid);
                oa->o_valid |= OBD_MD_FLUID;
        }
        if (ia_valid & ATTR_GID) {
-               oa->o_gid = attr->ia_gid;
+               oa->o_gid = from_kgid(&init_user_ns, attr->ia_gid);
                oa->o_valid |= OBD_MD_FLGID;
        }
 }
@@ -281,16 +281,16 @@ void iattr_from_obdo(struct iattr *attr, struct obdo *oa, obd_flag valid)
        if (valid & OBD_MD_FLMODE) {
                attr->ia_mode = (attr->ia_mode & S_IFMT)|(oa->o_mode & ~S_IFMT);
                attr->ia_valid |= ATTR_MODE;
-               if (!current_is_in_group(oa->o_gid) &&
+               if (!in_group_p(make_kgid(&init_user_ns, oa->o_gid)) &&
                    !cfs_capable(CFS_CAP_FSETID))
                        attr->ia_mode &= ~S_ISGID;
        }
        if (valid & OBD_MD_FLUID) {
-               attr->ia_uid = oa->o_uid;
+               attr->ia_uid = make_kuid(&init_user_ns, oa->o_uid);
                attr->ia_valid |= ATTR_UID;
        }
        if (valid & OBD_MD_FLGID) {
-               attr->ia_gid = oa->o_gid;
+               attr->ia_gid = make_kgid(&init_user_ns, oa->o_gid);
                attr->ia_valid |= ATTR_GID;
        }
 }
index 184195fde62134948a2b5a527c6ce47340d143d0..ae89ea6f893cf165eac25474f0e5b237e2663b31 100644 (file)
@@ -2097,10 +2097,14 @@ static void echo_ucred_init(struct lu_env *env)
        ucred->uc_suppgids[0] = -1;
        ucred->uc_suppgids[1] = -1;
 
-       ucred->uc_uid   = ucred->uc_o_uid   = current_uid();
-       ucred->uc_gid   = ucred->uc_o_gid   = current_gid();
-       ucred->uc_fsuid = ucred->uc_o_fsuid = current_fsuid();
-       ucred->uc_fsgid = ucred->uc_o_fsgid = current_fsgid();
+       ucred->uc_uid   = ucred->uc_o_uid   =
+                               from_kuid(&init_user_ns, current_uid());
+       ucred->uc_gid   = ucred->uc_o_gid   =
+                               from_kgid(&init_user_ns, current_gid());
+       ucred->uc_fsuid = ucred->uc_o_fsuid =
+                               from_kuid(&init_user_ns, current_fsuid());
+       ucred->uc_fsgid = ucred->uc_o_fsgid =
+                               from_kgid(&init_user_ns, current_fsgid());
        ucred->uc_cap   = cfs_curproc_cap_pack();
 
        /* remove fs privilege for non-root user. */
index 36e8bed5458afa61e8b405d09286a19b7307ae6c..349c57b6d78a3b14e1748d382e65c30625c6bd2a 100644 (file)
@@ -269,8 +269,8 @@ struct ptlrpc_cli_ctx *get_my_ctx(struct ptlrpc_sec *sec)
                        remove_dead = 0;
                }
        } else {
-               vcred.vc_uid = current_uid();
-               vcred.vc_gid = current_gid();
+               vcred.vc_uid = from_kuid(&init_user_ns, current_uid());
+               vcred.vc_gid = from_kgid(&init_user_ns, current_gid());
        }
 
        return sec->ps_policy->sp_cops->lookup_ctx(sec, &vcred,
@@ -1523,7 +1523,8 @@ void sptlrpc_import_flush_root_ctx(struct obd_import *imp)
 
 void sptlrpc_import_flush_my_ctx(struct obd_import *imp)
 {
-       import_flush_ctx_common(imp, current_uid(), 1, 1);
+       import_flush_ctx_common(imp, from_kuid(&init_user_ns, current_uid()),
+                               1, 1);
 }
 EXPORT_SYMBOL(sptlrpc_import_flush_my_ctx);
 
@@ -2055,8 +2056,8 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req)
 
        req->rq_flvr.sf_rpc = WIRE_FLVR(msg->lm_secflvr);
        req->rq_sp_from = LUSTRE_SP_ANY;
-       req->rq_auth_uid = INVALID_UID;
-       req->rq_auth_mapped_uid = INVALID_UID;
+       req->rq_auth_uid = -1;
+       req->rq_auth_mapped_uid = -1;
 
        policy = sptlrpc_wireflavor2policy(req->rq_flvr.sf_rpc);
        if (!policy) {
@@ -2314,10 +2315,10 @@ int sptlrpc_pack_user_desc(struct lustre_msg *msg, int offset)
 
        pud = lustre_msg_buf(msg, offset, 0);
 
-       pud->pud_uid = current_uid();
-       pud->pud_gid = current_gid();
-       pud->pud_fsuid = current_fsuid();
-       pud->pud_fsgid = current_fsgid();
+       pud->pud_uid = from_kuid(&init_user_ns, current_uid());
+       pud->pud_gid = from_kgid(&init_user_ns, current_gid());
+       pud->pud_fsuid = from_kuid(&init_user_ns, current_fsuid());
+       pud->pud_fsgid = from_kgid(&init_user_ns, current_fsgid());
        pud->pud_cap = cfs_curproc_cap_pack();
        pud->pud_ngroups = (msg->lm_buflens[offset] - sizeof(*pud)) / 4;