All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND] generic/673: Add separate sgid stripping sub-tests
@ 2022-04-26  8:55 Yang Xu
  2022-04-27  3:35 ` Darrick J. Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Xu @ 2022-04-26  8:55 UTC (permalink / raw)
  To: djwong; +Cc: fstests, Yang Xu

Even kernel doesn't get ATTR_KILL_SGID mask and get ATTR_KILL_SUID mask,
we still can strip S_ISGID mode in setattr_prepare and setattr_copy.

We should check separate sgid stripping logic whether works well
on different filesystems.

Also fix comments error.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 tests/generic/673     | 37 ++++++++++++++++++++++++++++++-------
 tests/generic/673.out | 24 ++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 7 deletions(-)

diff --git a/tests/generic/673 b/tests/generic/673
index 0377c5f6..e40e672a 100755
--- a/tests/generic/673
+++ b/tests/generic/673
@@ -53,8 +53,7 @@ commit_and_check() {
 	echo
 }
 
-# Commit to a non-exec file by an unprivileged user clears suid but leaves
-# sgid.
+# Commit to a non-exec file by an unprivileged user clears suid and sgid
 echo "Test 1 - qa_user, non-exec file"
 setup_testfile
 chmod a+rws $SCRATCH_MNT/a
@@ -66,7 +65,7 @@ setup_testfile
 chmod g+x,a+rws $SCRATCH_MNT/a
 commit_and_check "$qa_user"
 
-# Commit to a user-exec file by an unprivileged user clears suid but not sgid.
+# Commit to a user-exec file by an unprivileged user clears suid and sgid.
 echo "Test 3 - qa_user, user-exec file"
 setup_testfile
 chmod u+x,a+rws,g-x $SCRATCH_MNT/a
@@ -78,30 +77,54 @@ setup_testfile
 chmod a+rwxs $SCRATCH_MNT/a
 commit_and_check "$qa_user"
 
-# Commit to a non-exec file by root clears suid but leaves sgid.
+# Commit to a non-exec file by root leaves suid and sgid.
 echo "Test 5 - root, non-exec file"
 setup_testfile
 chmod a+rws $SCRATCH_MNT/a
 commit_and_check
 
-# Commit to a group-exec file by root clears suid and sgid.
+# Commit to a group-exec file by root leaves suid and sgid.
 echo "Test 6 - root, group-exec file"
 setup_testfile
 chmod g+x,a+rws $SCRATCH_MNT/a
 commit_and_check
 
-# Commit to a user-exec file by root clears suid but not sgid.
+# Commit to a user-exec file by root leaves suid and sgid.
 echo "Test 7 - root, user-exec file"
 setup_testfile
 chmod u+x,a+rws,g-x $SCRATCH_MNT/a
 commit_and_check
 
-# Commit to a all-exec file by root clears suid and sgid.
+# Commit to a all-exec file by root leaves suid and sgid.
 echo "Test 8 - root, all-exec file"
 setup_testfile
 chmod a+rwxs $SCRATCH_MNT/a
 commit_and_check
 
+#Commit to a non-exec file by an unprivileged user leaves sgid.
+echo "Test 9 - qa_user, non-exec file, only sgid"
+setup_testfile
+chmod a+rw,g+rws $SCRATCH_MNT/a
+commit_and_check "$qa_user"
+
+#Commit to a group-exec file by an unprivileged user clears sgid
+echo "Test 10 - qa_user, group-exec file, only sgid"
+setup_testfile
+chmod a+rw,g+rwxs $SCRATCH_MNT/a
+commit_and_check "$qa_user"
+
+#Commit to a user-exec file by an unprivileged user clears sgid
+echo "Test 11 - qa_user, user-exec file, only sgid"
+setup_testfile
+chmod a+rw,u+x,g+rws $SCRATCH_MNT/a
+commit_and_check "$qa_user"
+
+#Commit to a all-exec file by an unprivileged user clears sgid.
+echo "Test 12 - qa_user, all-exec file, only sgid"
+setup_testfile
+chmod a+rwx,g+rwxs $SCRATCH_MNT/a
+commit_and_check "$qa_user"
+
 # success, all done
 status=0
 exit
diff --git a/tests/generic/673.out b/tests/generic/673.out
index 4d18bca2..0817857d 100644
--- a/tests/generic/673.out
+++ b/tests/generic/673.out
@@ -47,3 +47,27 @@ Test 8 - root, all-exec file
 3784de23efab7a2074c9ec66901e39e5  SCRATCH_MNT/a
 6777 -rwsrwsrwx SCRATCH_MNT/a
 
+Test 9 - qa_user, non-exec file, only sgid
+310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
+2666 -rw-rwSrw- SCRATCH_MNT/a
+3784de23efab7a2074c9ec66901e39e5  SCRATCH_MNT/a
+2666 -rw-rwSrw- SCRATCH_MNT/a
+
+Test 10 - qa_user, group-exec file, only sgid
+310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
+2676 -rw-rwsrw- SCRATCH_MNT/a
+3784de23efab7a2074c9ec66901e39e5  SCRATCH_MNT/a
+676 -rw-rwxrw- SCRATCH_MNT/a
+
+Test 11 - qa_user, user-exec file, only sgid
+310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
+2766 -rwxrwSrw- SCRATCH_MNT/a
+3784de23efab7a2074c9ec66901e39e5  SCRATCH_MNT/a
+2766 -rwxrwSrw- SCRATCH_MNT/a
+
+Test 12 - qa_user, all-exec file, only sgid
+310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
+2777 -rwxrwsrwx SCRATCH_MNT/a
+3784de23efab7a2074c9ec66901e39e5  SCRATCH_MNT/a
+777 -rwxrwxrwx SCRATCH_MNT/a
+
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RESEND] generic/673: Add separate sgid stripping sub-tests
  2022-04-26  8:55 [RESEND] generic/673: Add separate sgid stripping sub-tests Yang Xu
@ 2022-04-27  3:35 ` Darrick J. Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2022-04-27  3:35 UTC (permalink / raw)
  To: Yang Xu; +Cc: fstests

On Tue, Apr 26, 2022 at 04:55:45PM +0800, Yang Xu wrote:
> Even kernel doesn't get ATTR_KILL_SGID mask and get ATTR_KILL_SUID mask,
> we still can strip S_ISGID mode in setattr_prepare and setattr_copy.
> 
> We should check separate sgid stripping logic whether works well
> on different filesystems.
> 
> Also fix comments error.
> 
> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>

LGTM
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  tests/generic/673     | 37 ++++++++++++++++++++++++++++++-------
>  tests/generic/673.out | 24 ++++++++++++++++++++++++
>  2 files changed, 54 insertions(+), 7 deletions(-)
> 
> diff --git a/tests/generic/673 b/tests/generic/673
> index 0377c5f6..e40e672a 100755
> --- a/tests/generic/673
> +++ b/tests/generic/673
> @@ -53,8 +53,7 @@ commit_and_check() {
>  	echo
>  }
>  
> -# Commit to a non-exec file by an unprivileged user clears suid but leaves
> -# sgid.
> +# Commit to a non-exec file by an unprivileged user clears suid and sgid
>  echo "Test 1 - qa_user, non-exec file"
>  setup_testfile
>  chmod a+rws $SCRATCH_MNT/a
> @@ -66,7 +65,7 @@ setup_testfile
>  chmod g+x,a+rws $SCRATCH_MNT/a
>  commit_and_check "$qa_user"
>  
> -# Commit to a user-exec file by an unprivileged user clears suid but not sgid.
> +# Commit to a user-exec file by an unprivileged user clears suid and sgid.
>  echo "Test 3 - qa_user, user-exec file"
>  setup_testfile
>  chmod u+x,a+rws,g-x $SCRATCH_MNT/a
> @@ -78,30 +77,54 @@ setup_testfile
>  chmod a+rwxs $SCRATCH_MNT/a
>  commit_and_check "$qa_user"
>  
> -# Commit to a non-exec file by root clears suid but leaves sgid.
> +# Commit to a non-exec file by root leaves suid and sgid.
>  echo "Test 5 - root, non-exec file"
>  setup_testfile
>  chmod a+rws $SCRATCH_MNT/a
>  commit_and_check
>  
> -# Commit to a group-exec file by root clears suid and sgid.
> +# Commit to a group-exec file by root leaves suid and sgid.
>  echo "Test 6 - root, group-exec file"
>  setup_testfile
>  chmod g+x,a+rws $SCRATCH_MNT/a
>  commit_and_check
>  
> -# Commit to a user-exec file by root clears suid but not sgid.
> +# Commit to a user-exec file by root leaves suid and sgid.
>  echo "Test 7 - root, user-exec file"
>  setup_testfile
>  chmod u+x,a+rws,g-x $SCRATCH_MNT/a
>  commit_and_check
>  
> -# Commit to a all-exec file by root clears suid and sgid.
> +# Commit to a all-exec file by root leaves suid and sgid.
>  echo "Test 8 - root, all-exec file"
>  setup_testfile
>  chmod a+rwxs $SCRATCH_MNT/a
>  commit_and_check
>  
> +#Commit to a non-exec file by an unprivileged user leaves sgid.
> +echo "Test 9 - qa_user, non-exec file, only sgid"
> +setup_testfile
> +chmod a+rw,g+rws $SCRATCH_MNT/a
> +commit_and_check "$qa_user"
> +
> +#Commit to a group-exec file by an unprivileged user clears sgid
> +echo "Test 10 - qa_user, group-exec file, only sgid"
> +setup_testfile
> +chmod a+rw,g+rwxs $SCRATCH_MNT/a
> +commit_and_check "$qa_user"
> +
> +#Commit to a user-exec file by an unprivileged user clears sgid
> +echo "Test 11 - qa_user, user-exec file, only sgid"
> +setup_testfile
> +chmod a+rw,u+x,g+rws $SCRATCH_MNT/a
> +commit_and_check "$qa_user"
> +
> +#Commit to a all-exec file by an unprivileged user clears sgid.
> +echo "Test 12 - qa_user, all-exec file, only sgid"
> +setup_testfile
> +chmod a+rwx,g+rwxs $SCRATCH_MNT/a
> +commit_and_check "$qa_user"
> +
>  # success, all done
>  status=0
>  exit
> diff --git a/tests/generic/673.out b/tests/generic/673.out
> index 4d18bca2..0817857d 100644
> --- a/tests/generic/673.out
> +++ b/tests/generic/673.out
> @@ -47,3 +47,27 @@ Test 8 - root, all-exec file
>  3784de23efab7a2074c9ec66901e39e5  SCRATCH_MNT/a
>  6777 -rwsrwsrwx SCRATCH_MNT/a
>  
> +Test 9 - qa_user, non-exec file, only sgid
> +310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
> +2666 -rw-rwSrw- SCRATCH_MNT/a
> +3784de23efab7a2074c9ec66901e39e5  SCRATCH_MNT/a
> +2666 -rw-rwSrw- SCRATCH_MNT/a
> +
> +Test 10 - qa_user, group-exec file, only sgid
> +310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
> +2676 -rw-rwsrw- SCRATCH_MNT/a
> +3784de23efab7a2074c9ec66901e39e5  SCRATCH_MNT/a
> +676 -rw-rwxrw- SCRATCH_MNT/a
> +
> +Test 11 - qa_user, user-exec file, only sgid
> +310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
> +2766 -rwxrwSrw- SCRATCH_MNT/a
> +3784de23efab7a2074c9ec66901e39e5  SCRATCH_MNT/a
> +2766 -rwxrwSrw- SCRATCH_MNT/a
> +
> +Test 12 - qa_user, all-exec file, only sgid
> +310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
> +2777 -rwxrwsrwx SCRATCH_MNT/a
> +3784de23efab7a2074c9ec66901e39e5  SCRATCH_MNT/a
> +777 -rwxrwxrwx SCRATCH_MNT/a
> +
> -- 
> 2.27.0
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-27  3:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26  8:55 [RESEND] generic/673: Add separate sgid stripping sub-tests Yang Xu
2022-04-27  3:35 ` Darrick J. Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.