From 1504473051df3d20e824f1064ee134501f3856e8 Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Tue, 29 Apr 2014 16:24:59 -0400 Subject: [PATCH] LU-4924 llite: Only kill SGID/SUID bits 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 Change-Id: Ic452590a6fb59010f1ee6b8b0b790557a2540d8c Reviewed-on: http://review.whamcloud.com/10153 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Andreas Dilger --- lustre/llite/llite_lib.c | 6 ++++-- lustre/tests/Makefile.am | 3 ++- lustre/tests/acl/4924.test | 13 +++++++++++++ lustre/tests/sanity.sh | 2 ++ 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 lustre/tests/acl/4924.test diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 9b09581..3aa25aa 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -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; diff --git a/lustre/tests/Makefile.am b/lustre/tests/Makefile.am index d0e657c..6d730d5 100644 --- a/lustre/tests/Makefile.am +++ b/lustre/tests/Makefile.am @@ -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 index 0000000..9b8a0c2 --- /dev/null +++ b/lustre/tests/acl/4924.test @@ -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 diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 849b125..e9e29f3 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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 -- 1.8.3.1