Whamcloud - gitweb
LU-4924 llite: Only kill SGID/SUID bits 53/10153/3
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, 13 May 2014 14:43:42 +0000 (14:43 +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: Ic452590a6fb59010f1ee6b8b0b790557a2540d8c
Reviewed-on: http://review.whamcloud.com/10153
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@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 9b09581..3aa25aa 100644 (file)
@@ -1796,12 +1796,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 d0e657c..6d730d5 100644 (file)
@@ -49,7 +49,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 acl/2561.test acl/2561_zfs.test
+nobase_noinst_DATA += acl/974.test acl/974_remote.test
+nobase_noinst_DATA += acl/2561.test acl/2561_zfs.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 849b125..e9e29f3 100644 (file)
@@ -6738,6 +6738,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