Whamcloud - gitweb
LU-4924 llite: Only kill SGID/SUID bits 71/10071/2
authorNathaniel Clark <nathaniel.l.clark@intel.com>
Wed, 23 Apr 2014 21:39:46 +0000 (17:39 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 29 Apr 2014 17:54:31 +0000 (17:54 +0000)
Check that attr mode is valid before using it when determining if to
clear SGID and SUID bits in ll_setattr.
Add regression test.

Signed-off-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Change-Id: I2b221e80a5bb167f8670f376ce97d62d720ad857
Reviewed-on: http://review.whamcloud.com/10071
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
lustre/llite/llite_lib.c
lustre/tests/acl/4924.test [new file with mode: 0644]
lustre/tests/sanity.sh

index 40961da..8cf1e31 100644 (file)
@@ -1787,12 +1787,14 @@ int ll_setattr(struct dentry *de, struct iattr *attr)
              !(attr->ia_mode & S_ISGID))))
                attr->ia_valid |= ATTR_FORCE;
 
-       if ((mode & S_ISUID) &&
+       if ((attr->ia_valid & ATTR_MODE) &&
+           (mode & S_ISUID) &&
            !(attr->ia_mode & S_ISUID) &&
            !(attr->ia_valid & ATTR_KILL_SUID))
                attr->ia_valid |= ATTR_KILL_SUID;
 
-       if (((mode & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP)) &&
+       if ((attr->ia_valid & ATTR_MODE) &&
+           ((mode & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP)) &&
            !(attr->ia_mode & S_ISGID) &&
            !(attr->ia_valid & ATTR_KILL_SGID))
                attr->ia_valid |= ATTR_KILL_SGID;
diff --git a/lustre/tests/acl/4924.test b/lustre/tests/acl/4924.test
new file mode 100644 (file)
index 0000000..9b8a0c2
--- /dev/null
@@ -0,0 +1,13 @@
+LU-4924 - chmod g+s, touch should not clear sgid bit
+
+       $ mkdir 4924
+       $ cd 4924
+       $ touch f
+       $ chmod u=rwx,g=rwxs f
+       $ ls -l f | awk -- '{ print $1, $3, $4 }'
+       > -rwxrwsr-- root root
+       $ touch f
+       $ ls -l f | awk -- '{ print $1, $3, $4 }'
+       > -rwxrwsr-- root root
+       $ cd ..
+       $ rm -rf 4924
index 57fbe1a..42d8eff 100644 (file)
@@ -6699,6 +6699,8 @@ test_103 () {
                run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
        fi
 
+       run_acl_subtest 4924 || error "LU-4924 test failed"
+
        cd $SAVE_PWD
        umask $SAVE_UMASK