Whamcloud - gitweb
LU-4924 llite: Only kill SGID/SUID bits 05/10405/2
authorNathaniel Clark <nathaniel.l.clark@intel.com>
Tue, 29 Apr 2014 20:24:59 +0000 (16:24 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 27 May 2014 15:46:28 +0000 (15:46 +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.

Lustre-commit: 1504473051df3d20e824f1064ee134501f3856e8
Lustre-change: http://review.whamcloud.com/10153

Signed-off-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Signed-off-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I3c8382d6f0899ce9190ccb2993af4c508942b316
Reviewed-on: http://review.whamcloud.com/10405
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/llite_lib.c
lustre/tests/Makefile.am
lustre/tests/acl/4924.test [new file with mode: 0644]
lustre/tests/sanity.sh

index 1015760..c8fc0cc 100644 (file)
@@ -1582,12 +1582,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;
index 0f18405..06ef9ee 100644 (file)
@@ -48,6 +48,8 @@ nobase_noinst_SCRIPTS += rmtacl/make-tree rmtacl/run
 nobase_noinst_SCRIPTS += posix/posix.cfg
 nobase_noinst_DATA = acl/cp.test acl/getfacl-noacl.test acl/inheritance.test
 nobase_noinst_DATA += acl/misc.test acl/permissions.test acl/setfacl.test
+nobase_noinst_DATA += acl/974.test acl/974_remote.test
+nobase_noinst_DATA += acl/2561.test acl/4924.test
 nobase_noinst_DATA += rmtacl/misc.test rmtacl/permissions.test
 nobase_noinst_DATA += rmtacl/setfacl.test rmtacl/cp.test
 nobase_noinst_DATA += rmtacl/getfacl-noacl.test rmtacl/inheritance.test
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 97178c5..13d47ee 100644 (file)
@@ -6608,6 +6608,8 @@ test_103 () {
        echo "LU-2561 newly created file is same size as directory..."
        run_acl_subtest 2561 || error "LU-2561 test failed"
 
+       run_acl_subtest 4924 || error "LU-4924 test failed"
+
        cd $SAVE_PWD
        umask $SAVE_UMASK