Whamcloud - gitweb
LU-5058 llite: support root squash on newer kernels 25/10325/2
authorJames Simmons <uja.ornl@gmail.com>
Tue, 13 May 2014 23:05:07 +0000 (19:05 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 30 May 2014 04:19:44 +0000 (04:19 +0000)
The fix for the root squash bug for LU-1778 does not
handle the new namespace changes in newer kernels.
This patch restores that functionality.

Change-Id: I2b3bd8a18b94108cc78f55e33f61fa788e353721
Signed-off-by: James Simmons <uja.ornl@gmail.com>
Reviewed-on: http://review.whamcloud.com/10325
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Grégoire Pichon <gregoire.pichon@bull.net>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/include/libcfs/curproc.h
lustre/llite/file.c

index fc18b12..e5e3d57 100644 (file)
@@ -51,6 +51,9 @@ typedef gid_t kgid_t;
 #define INVALID_UID     -1
 #define INVALID_GID     -1
 
 #define INVALID_UID     -1
 #define INVALID_GID     -1
 
+#define GLOBAL_ROOT_UID         0
+#define GLOBAL_ROOT_GID         0
+
 #ifndef __KERNEL__
 struct user_namespace {
        unsigned int pad;
 #ifndef __KERNEL__
 struct user_namespace {
        unsigned int pad;
index 2450897..2d2451b 100644 (file)
@@ -3542,13 +3542,13 @@ int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd)
        sbi = ll_i2sbi(inode);
        squash = &sbi->ll_squash;
        if (unlikely(squash->rsi_uid != 0 &&
        sbi = ll_i2sbi(inode);
        squash = &sbi->ll_squash;
        if (unlikely(squash->rsi_uid != 0 &&
-                    current_fsuid() == 0 &&
+                    uid_eq(current_fsuid(), GLOBAL_ROOT_UID) &&
                     !(sbi->ll_flags & LL_SBI_NOROOTSQUASH))) {
                        squash_id = true;
        }
        if (squash_id) {
                CDEBUG(D_OTHER, "squash creds (%d:%d)=>(%d:%d)\n",
                     !(sbi->ll_flags & LL_SBI_NOROOTSQUASH))) {
                        squash_id = true;
        }
        if (squash_id) {
                CDEBUG(D_OTHER, "squash creds (%d:%d)=>(%d:%d)\n",
-                      current_fsuid(), current_fsgid(),
+                      __kuid_val(current_fsuid()), __kgid_val(current_fsgid()),
                       squash->rsi_uid, squash->rsi_gid);
 
                /* update current process's credentials
                       squash->rsi_uid, squash->rsi_gid);
 
                /* update current process's credentials
@@ -3557,8 +3557,8 @@ int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd)
                if (cred == NULL)
                        RETURN(-ENOMEM);
 
                if (cred == NULL)
                        RETURN(-ENOMEM);
 
-               cred->fsuid = squash->rsi_uid;
-               cred->fsgid = squash->rsi_gid;
+               cred->fsuid = make_kuid(&init_user_ns, squash->rsi_uid);
+               cred->fsgid = make_kgid(&init_user_ns, squash->rsi_gid);
                for (cap = 0; cap < sizeof(cfs_cap_t) * 8; cap++) {
                        if ((1 << cap) & CFS_CAP_FS_MASK)
                                cap_lower(cred->cap_effective, cap);
                for (cap = 0; cap < sizeof(cfs_cap_t) * 8; cap++) {
                        if ((1 << cap) & CFS_CAP_FS_MASK)
                                cap_lower(cred->cap_effective, cap);