From: Nathaniel Clark Date: Wed, 23 Apr 2014 21:39:46 +0000 (-0400) Subject: LU-4924 llite: Only kill SGID/SUID bits X-Git-Tag: 2.5.59~77 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=70c37954649fbc4fc2d0820d5d422f96144071f9 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: I2b221e80a5bb167f8670f376ce97d62d720ad857 Reviewed-on: http://review.whamcloud.com/10071 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Lai Siyao --- diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 40961da..8cf1e31 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -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 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 57fbe1a..42d8eff 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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