Skip to contentSkip to conversation

syscalls/creat09: Add umask test condition

PATCH In review Yang Xu 3 participants 18 messages Sep 14, 2022 – Oct 10, 2022 Library code

lore
Share & tools
lore

Yang Xu

author
#0 lore raw

PATCH v4 1/3 syscalls/creat09: Add umask test condition

A kernel patch set that fix setgid strip logic under umask(S_IXGRP) found by this case has been merged into 6.0-rc1 kernel[1].

I will add acl and umask test[2] in xfstests because there is more suitable to do this.

Here I just only add umask test condition simply.

[1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1639a49c [2]https://patchwork.kernel.org/project/fstests/list/?series=662984

---
 testcases/kernel/syscalls/creat/creat09.c | 30 +++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/creat/creat09.c +28 -2
index bed7bddb0..d583cceca 100644
@@ -28,6 +28,16 @@
  *  Date:   Fri Jan 22 16:48:18 2021 -0800
  *
  *  xfs: fix up non-directory creation in SGID directories
+ *
+ * When use acl or umask, it still has bug.
+ *
+ * Fixed in:
+ *
+ *  commit 1639a49ccdce58ea248841ed9b23babcce6dbb0b
+ *  Author: Yang Xu <[email protected]>
+ *  Date:   Thu July 14 14:11:27 2022 +0800
+ *
+ *  fs: move S_ISGID stripping into the vfs_*() helpers
  */
 
 #include <stdlib.h>
@@ -47,6 +57,14 @@
 static gid_t free_gid;
 static int fd = -1;
 
+static struct tcase {
+	const char *msg;
+	int mask;
+} tcases[] = {
+	{"under umask(0) situation", 0},
+	{"under umask(S_IXGRP) situation", S_IXGRP}
+};
+
 static void setup(void)
 {
 	struct stat buf;
@@ -94,8 +112,14 @@ static void file_test(const char *name)
 		tst_res(TPASS, "%s: Setgid bit not set", name);
 }
 
-static void run(void)
+static void run(unsigned int n)
 {
+	struct tcase *tc = &tcases[n];
+
+	umask(tc->mask);
+	tst_res(TINFO, "Testing setgid behaviour when creating file %s",
+			tc->msg);
+
 	fd = SAFE_CREAT(CREAT_FILE, MODE_SGID);
 	SAFE_CLOSE(fd);
 	file_test(CREAT_FILE);
@@ -115,13 +139,14 @@ static void cleanup(void)
 }
 
 static struct tst_test test = {
-	.test_all = run,
+	.test = run,
 	.setup = setup,
 	.cleanup = cleanup,
 	.needs_root = 1,
 	.all_filesystems = 1,
 	.mount_device = 1,
 	.mntpoint = MNTPOINT,
+	.tcnt = ARRAY_SIZE(tcases),
 	.skip_filesystems = (const char*[]) {
 		"exfat",
 		"ntfs",
@@ -132,6 +157,7 @@ static struct tst_test test = {
 		{"linux-git", "0fa3ecd87848"},
 		{"CVE", "2018-13405"},
 		{"linux-git", "01ea173e103e"},
+		{"linux-git", "1639a49ccdce"},
 		{}
 	},
 };
Signature · 5 lines
2.23.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw

PATCH v4 2/3 tst_safe_file_at: Add SAFE_FSTATAT macro

---
 include/tst_safe_file_at.h |  7 +++++++
 lib/tst_safe_file_at.c     | 20 ++++++++++++++++++++
 2 files changed, 27 insertions(+)
include/tst_safe_file_at.h +7 -0
index e253198e6..082a5acd9 100644
@@ -29,6 +29,9 @@
 	safe_fchownat(__FILE__, __LINE__,				\
 			(dirfd), (path), (owner), (group), (flags))
 
+#define SAFE_FSTATAT(dirfd, path, statbuf, flags)			\
+	safe_fstatat(__FILE__, __LINE__, (dirfd), (path), (statbuf), (flags))
+
 const char *tst_decode_fd(const int fd)
 			  __attribute__((warn_unused_result));
 
@@ -67,4 +70,8 @@ int safe_fchownat(const char *const file, const int lineno,
 		  gid_t group, int flags)
 		  __attribute__ ((nonnull));
 
+int safe_fstatat(const char *const file, const int lineno,
+		 const int dirfd, const char *const path, struct stat *statbuf,
+		 int flags)
+		 __attribute__ ((nonnull));
 #endif
lib/tst_safe_file_at.c +20 -0
index 6370a68e5..f530dc349 100644
@@ -215,3 +215,23 @@ int safe_fchownat(const char *const file, const int lineno,
 
 	return rval;
 }
+
+int safe_fstatat(const char *const file, const int lineno,
+		 const int dirfd, const char *const path, struct stat *statbuf, int flags)
+{
+	int rval;
+
+	rval = fstatat(dirfd, path, statbuf, flags);
+
+	if (rval == -1) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			 "fstatat(%d<%s>, '%s', %p, %d) failed", dirfd,
+			 tst_decode_fd(dirfd), path, statbuf, flags);
+	} else if (rval) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			 "Invalid fstatat(%d<%s>, '%s', %p, %d) return value %d",
+			 dirfd, tst_decode_fd(dirfd), path, statbuf, flags, rval);
+	}
+
+	return rval;
+}
Signature · 5 lines
2.23.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#3 lore raw

PATCH v4 3/3 syscalls/openat: Add new regression test when using open(O_TMPFILE) under umask

In reply to Yang Xu
---
 runtest/syscalls                            |   2 +-
 testcases/kernel/syscalls/openat/.gitignore |   1 +
 testcases/kernel/syscalls/openat/openat04.c | 181 ++++++++++++++++++++
 3 files changed, 183 insertions(+), 1 deletion(-)
 create mode 100644 testcases/kernel/syscalls/openat/openat04.c
runtest/syscalls +1 -1
index 9d58e0aa1..cd38a4ddf 100644
@@ -919,10 +919,10 @@ open12 open12
 open13 open13
 open14 open14
 
-#openat test cases
 openat01 openat01
 openat02 openat02
 openat03 openat03
+openat04 openat04
 
 openat201 openat201
 openat202 openat202
testcases/kernel/syscalls/openat/.gitignore +1 -0
index 2928dae22..2d15872ab 100644
@@ -2,3 +2,4 @@
 /openat02
 /openat02_child
 /openat03
+/openat04
testcases/kernel/syscalls/openat/openat04.c new file +181 -0

181 lines not on this page · raw message

Signature · 5 lines
2.23.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Re: [LTP] [PATCH v4 3/3] syscalls/openat: Add new regression test when using open(O_TMPFILE) under umask

Hi!
And this one is probably missing some kernel commit tags too, since the only that that is attached is supposedly in 5.19 but the test still fails.

I supposed that we should add the 426b4ca2d6a5 to the test tags here as well, right?

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

Re: [LTP] [PATCH v4 3/3] syscalls/openat: Add new regression test when using open(O_TMPFILE) under umask

Hi Cyril

Quoted 4 lines

Hi!
And this one is probably missing some kernel commit tags too, since the only that that is attached is supposedly in 5.19 but the test still fails.

I supposed that we should add the 426b4ca2d6a5 to the test tags here as well, right?

Yes, BTW, I usually use git tag --contains command, so I know this kernel fix is belong to 6.0.

git tag --contains ac6800e27
v6.0-rc1
v6.0-rc2

Best Regards
Yang Xu

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Re: [LTP] [PATCH v4 3/3] syscalls/openat: Add new regression test when using open(O_TMPFILE) under umask

Hi!

Quoted 9 lines
Quoted 3 lines

And this one is probably missing some kernel commit tags too, since the only that that is attached is supposedly in 5.19 but the test still fails.

I supposed that we should add the 426b4ca2d6a5 to the test tags here as well, right?

Yes, BTW, I usually use git tag --contains command, so I know this kernel fix is belong to 6.0.

git tag --contains ac6800e27
v6.0-rc1
v6.0-rc2

Now I'm confused, if I do git describe ac6800e27 it says that it's a second commit on the top of 5.19-rc7. So shouldn't the the git tag --contains report 5.19-rc8 and newer? What do I miss?

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

Re: [LTP] [PATCH v4 3/3] syscalls/openat: Add new regression test when using open(O_TMPFILE) under umask

Hi Cyril

Quoted 11 lines
Quoted 9 lines
Quoted 4 lines

And this one is probably missing some kernel commit tags too, since the only that that is attached is supposedly in 5.19 but the test still fails.

I supposed that we should add the 426b4ca2d6a5 to the test tags here as well, right?

Yes, BTW, I usually use git tag --contains command, so I know this kernel fix is belong to 6.0.

git tag --contains ac6800e27
v6.0-rc1
v6.0-rc2

Now I'm confused, if I do git describe ac6800e27 it says that it's a second commit on the top of 5.19-rc7. So shouldn't the the git tag --contains report 5.19-rc8 and newer? What do I miss?

I don't know about this. It is a detail in kernel community collaborative work .
But kernel subsystem maintainer should be aware of this. @ Christian Brauner Can you help Cyril settle this confuse ?

Best Regards
Yang Xu

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

Re: [LTP] [PATCH v4 3/3] syscalls/openat: Add new regression test when using open(O_TMPFILE) under umask

In reply to Cyril Hrubis
Quoted 7 lines · Cyril Hrubis

Hi!

Quoted 6 lines
Quoted 3 lines

And this one is probably missing some kernel commit tags too, since the only that that is attached is supposedly in 5.19 but the test still fails.

I supposed that we should add the 426b4ca2d6a5 to the test tags here as well, right?

Yes, BTW, I usually use git tag --contains command, so I know this kernel fix is belong to 6.0.

Quoted 7 lines
Quoted 3 lines

git tag --contains ac6800e27
v6.0-rc1
v6.0-rc2

Now I'm confused, if I do git describe ac6800e27 it says that it's a second commit on the top of 5.19-rc7. So shouldn't the the git tag --contains report 5.19-rc8 and newer? What do I miss?

So, ac6800e279a2 ("fs: Add missing umask strip in vfs_tmpfile") has been backported to kernels since before the dawn of time. But the the all the pieces that move setgid handling out of individual filesystems and into the vfs proper are only >= v6.0-rc1.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#9 lore raw

Re: [LTP] [PATCH v4 3/3] syscalls/openat: Add new regression test when using open(O_TMPFILE) under umask

Hi Christian

Quoted 12 lines · Cyril Hrubis
Quoted 11 lines

Hi!

Quoted 9 lines
Quoted 3 lines

And this one is probably missing some kernel commit tags too, since the only that that is attached is supposedly in 5.19 but the test still fails.

I supposed that we should add the 426b4ca2d6a5 to the test tags here as well, right?

Yes, BTW, I usually use git tag --contains command, so I know this kernel fix is belong to 6.0.

git tag --contains ac6800e27
v6.0-rc1
v6.0-rc2

Quoted 8 lines
Quoted 3 lines

Now I'm confused, if I do git describe ac6800e27 it says that it's a second commit on the top of 5.19-rc7. So shouldn't the the git tag --contains report 5.19-rc8 and newer? What do I miss?

So, ac6800e279a2 ("fs: Add missing umask strip in vfs_tmpfile") has been backported to kernels since before the dawn of time. But the the all the pieces that move setgid handling out of individual filesystems and into the vfs proper are only >= v6.0-rc1.

I search the commit mesage in the following url,but not find c6800e279a2 commit

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?h=v5.19

@Cyril
I guess git describe ac6800e2 will serach the commit id because it is merge request"Merge tag 'fs.setgid.v6.0' of
git://git.kernel.org/pub/scm/linux/kerne/git/brauner/linux"
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=426b4ca2d6a5

then it will serach brauner linux fs.setgid. branch see the following url
https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/log/?h=fs.setgid

so git describe ac6800e27 it says that it's a second commit on the top of 5.19-rc7.

Best Regards
Yang Xu

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw

Re: [LTP] [PATCH v4 3/3] syscalls/openat: Add new regression test when using open(O_TMPFILE) under umask

Hi Cyril

Quoted 34 lines

Hi Christian

Quoted 12 lines · Cyril Hrubis
Quoted 11 lines

Hi!

Quoted 9 lines
Quoted 3 lines

And this one is probably missing some kernel commit tags too, since the only that that is attached is supposedly in 5.19 but the test still fails.

I supposed that we should add the 426b4ca2d6a5 to the test tags here as well, right?

Yes, BTW, I usually use git tag --contains command, so I know this kernel fix is belong to 6.0.

git tag --contains ac6800e27
v6.0-rc1
v6.0-rc2

Quoted 8 lines
Quoted 3 lines

Now I'm confused, if I do git describe ac6800e27 it says that it's a second commit on the top of 5.19-rc7. So shouldn't the the git tag --contains report 5.19-rc8 and newer? What do I miss?

So, ac6800e279a2 ("fs: Add missing umask strip in vfs_tmpfile") has been backported to kernels since before the dawn of time. But the the all the pieces that move setgid handling out of individual filesystems and into the vfs proper are only >= v6.0-rc1.

I search the commit mesage in the following url,but not find c6800e279a2 commit

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?h=v5.19

@Cyril
I guess git describe ac6800e2 will serach the commit id because it is merge request"Merge tag 'fs.setgid.v6.0' of
git://git.kernel.org/pub/scm/linux/kerne/git/brauner/linux"
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=426b4ca2d6a5

Quoted 6 lines

then it will serach brauner linux fs.setgid. branch see the following url
https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/log/?h=fs.setgid

so git describe ac6800e27 it says that it's a second commit on the top of 5.19-rc7.

So do you still have doubt on this? I don't think this should block this two patches.

Best Regards
Yang Xu

Quoted 5 lines

Best Regards
Yang Xu

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#11 lore raw
In reply to Yang Xu

Hi All

Quoted 10 lines

A kernel patch set that fix setgid strip logic under umask(S_IXGRP) found by this case has been merged into 6.0-rc1 kernel[1].

I will add acl and umask test[2] in xfstests because there is more suitable to do this.

Here I just only add umask test condition simply.

[1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1639a49c [2]https://patchwork.kernel.org/project/fstests/list/?series=662984

I Should update the [2] url because the corresponding patch is in xfstest for-next branch.

[2]https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/commit/?h=for-next&id=c875434286737e792d200cda2eb679e2a8441837

Also miss Acked-by: Christian Brauner (Microsoft) <[email protected]> tag.

Best Regards
Yang Xu

Quoted 83 lines
---
  testcases/kernel/syscalls/creat/creat09.c | 30 +++++++++++++++++++++--
  1 file changed, 28 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/creat/creat09.c +28 -2
index bed7bddb0..d583cceca 100644
@@ -28,6 +28,16 @@
   *  Date:   Fri Jan 22 16:48:18 2021 -0800
   *
   *  xfs: fix up non-directory creation in SGID directories
+ *
+ * When use acl or umask, it still has bug.
+ *
+ * Fixed in:
+ *
+ *  commit 1639a49ccdce58ea248841ed9b23babcce6dbb0b
+ *  Author: Yang Xu <[email protected]>
+ *  Date:   Thu July 14 14:11:27 2022 +0800
+ *
+ *  fs: move S_ISGID stripping into the vfs_*() helpers
   */
 
  #include <stdlib.h>
@@ -47,6 +57,14 @@
  static gid_t free_gid;
  static int fd = -1;
 
+static struct tcase {
+	const char *msg;
+	int mask;
+} tcases[] = {
+	{"under umask(0) situation", 0},
+	{"under umask(S_IXGRP) situation", S_IXGRP}
+};
+
  static void setup(void)
  {
  	struct stat buf;
@@ -94,8 +112,14 @@ static void file_test(const char *name)
  		tst_res(TPASS, "%s: Setgid bit not set", name);
  }
 
-static void run(void)
+static void run(unsigned int n)
  {
+	struct tcase *tc = &tcases[n];
+
+	umask(tc->mask);
+	tst_res(TINFO, "Testing setgid behaviour when creating file %s",
+			tc->msg);
+
  	fd = SAFE_CREAT(CREAT_FILE, MODE_SGID);
  	SAFE_CLOSE(fd);
  	file_test(CREAT_FILE);
@@ -115,13 +139,14 @@ static void cleanup(void)
  }
 
  static struct tst_test test = {
-	.test_all = run,
+	.test = run,
  	.setup = setup,
  	.cleanup = cleanup,
  	.needs_root = 1,
  	.all_filesystems = 1,
  	.mount_device = 1,
  	.mntpoint = MNTPOINT,
+	.tcnt = ARRAY_SIZE(tcases),
  	.skip_filesystems = (const char*[]) {
  		"exfat",
  		"ntfs",
@@ -132,6 +157,7 @@ static struct tst_test test = {
  		{"linux-git", "0fa3ecd87848"},
  		{"CVE", "2018-13405"},
  		{"linux-git", "01ea173e103e"},
+		{"linux-git", "1639a49ccdce"},
  		{}
  	},
  };
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#12 lore raw
In reply to Yang Xu

Hi!

Quoted 38 lines
testcases/kernel/syscalls/creat/creat09.c +18 -0
index bed7bddb0..d583cceca 100644
@@ -28,6 +28,16 @@
  *  Date:   Fri Jan 22 16:48:18 2021 -0800
  *
  *  xfs: fix up non-directory creation in SGID directories
+ *
+ * When use acl or umask, it still has bug.
+ *
+ * Fixed in:
+ *
+ *  commit 1639a49ccdce58ea248841ed9b23babcce6dbb0b
+ *  Author: Yang Xu <[email protected]>
+ *  Date:   Thu July 14 14:11:27 2022 +0800
+ *
+ *  fs: move S_ISGID stripping into the vfs_*() helpers
  */
 
 #include <stdlib.h>
@@ -47,6 +57,14 @@
 static gid_t free_gid;
 static int fd = -1;
 
+static struct tcase {
+	const char *msg;
+	int mask;
+} tcases[] = {
+	{"under umask(0) situation", 0},
+	{"under umask(S_IXGRP) situation", S_IXGRP}
+};
+
 static void setup(void)
 {
 	struct stat buf;
@@ -94,8 +112,14 @@ static void file_test(const char *name)
 		tst_res(TPASS, "%s: Setgid bit not set", name);

testcases/kernel/syscalls/creat/creat09.c static void file_test(const char *name) · line 121

Quoted 10 lines
testcases/kernel/syscalls/creat/creat09.c +6 -1
 }
 
-static void run(void)
+static void run(unsigned int n)
 {
+	struct tcase *tc = &tcases[n];
+
+	umask(tc->mask);
+	tst_res(TINFO, "Testing setgid behaviour when creating file %s",
+			tc->msg);

This can be shorter and more to the point, something as:

	tst_res(TINFO, "File created with %s", tc->msg);

And the msg could be just "umask(0)" and "umask(S_IXGRP)".

Otherwise it's fine and I can fix the messages before applying if you want.

Quoted 30 lines
testcases/kernel/syscalls/creat/creat09.c +3 -1
 	fd = SAFE_CREAT(CREAT_FILE, MODE_SGID);
 	SAFE_CLOSE(fd);
 	file_test(CREAT_FILE);
@@ -115,13 +139,14 @@ static void cleanup(void)
 }
 
 static struct tst_test test = {
-	.test_all = run,
+	.test = run,
 	.setup = setup,
 	.cleanup = cleanup,
 	.needs_root = 1,
 	.all_filesystems = 1,
 	.mount_device = 1,
 	.mntpoint = MNTPOINT,
+	.tcnt = ARRAY_SIZE(tcases),
 	.skip_filesystems = (const char*[]) {
 		"exfat",
 		"ntfs",
@@ -132,6 +157,7 @@ static struct tst_test test = {
 		{"linux-git", "0fa3ecd87848"},
 		{"CVE", "2018-13405"},
 		{"linux-git", "01ea173e103e"},
+		{"linux-git", "1639a49ccdce"},
 		{}
 	},
 };
Signature · 1 line
2.23.0
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#13 lore raw

Hi Cyril

Quoted 52 lines

Hi!

Quoted 38 lines
testcases/kernel/syscalls/creat/creat09.c +18 -0
index bed7bddb0..d583cceca 100644
@@ -28,6 +28,16 @@
   *  Date:   Fri Jan 22 16:48:18 2021 -0800
   *
   *  xfs: fix up non-directory creation in SGID directories
+ *
+ * When use acl or umask, it still has bug.
+ *
+ * Fixed in:
+ *
+ *  commit 1639a49ccdce58ea248841ed9b23babcce6dbb0b
+ *  Author: Yang Xu <[email protected]>
+ *  Date:   Thu July 14 14:11:27 2022 +0800
+ *
+ *  fs: move S_ISGID stripping into the vfs_*() helpers
   */
 
  #include <stdlib.h>
@@ -47,6 +57,14 @@
  static gid_t free_gid;
  static int fd = -1;
 
+static struct tcase {
+	const char *msg;
+	int mask;
+} tcases[] = {
+	{"under umask(0) situation", 0},
+	{"under umask(S_IXGRP) situation", S_IXGRP}
+};
+
  static void setup(void)
  {
  	struct stat buf;
@@ -94,8 +112,14 @@ static void file_test(const char *name)
  		tst_res(TPASS, "%s: Setgid bit not set", name);

testcases/kernel/syscalls/creat/creat09.c static void file_test(const char *name) · line 121

Quoted 10 lines
testcases/kernel/syscalls/creat/creat09.c +6 -1
  }
 
-static void run(void)
+static void run(unsigned int n)
  {
+	struct tcase *tc = &tcases[n];
+
+	umask(tc->mask);
+	tst_res(TINFO, "Testing setgid behaviour when creating file %s",
+			tc->msg);

This can be shorter and more to the point, something as:

Quoted 7 lines
	tst_res(TINFO, "File created with %s", tc->msg);

And the msg could be just "umask(0)" and "umask(S_IXGRP)".

Otherwise it's fine and I can fix the messages before applying if you want.

Yes. Please apply it with fix the messages. Thanks.

Best Regards
Yang Xu

Quoted 32 lines
Quoted 31 lines
testcases/kernel/syscalls/creat/creat09.c +3 -1
  	fd = SAFE_CREAT(CREAT_FILE, MODE_SGID);
  	SAFE_CLOSE(fd);
  	file_test(CREAT_FILE);
@@ -115,13 +139,14 @@ static void cleanup(void)
  }
 
  static struct tst_test test = {
-	.test_all = run,
+	.test = run,
  	.setup = setup,
  	.cleanup = cleanup,
  	.needs_root = 1,
  	.all_filesystems = 1,
  	.mount_device = 1,
  	.mntpoint = MNTPOINT,
+	.tcnt = ARRAY_SIZE(tcases),
  	.skip_filesystems = (const char*[]) {
  		"exfat",
  		"ntfs",
@@ -132,6 +157,7 @@ static struct tst_test test = {
  		{"linux-git", "0fa3ecd87848"},
  		{"CVE", "2018-13405"},
  		{"linux-git", "01ea173e103e"},
+		{"linux-git", "1639a49ccdce"},
  		{}
  	},
  };
Signature · 1 line
2.23.0
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#14 lore raw

Hi Cyril

Quoted 56 lines

Hi Cyril

Quoted 54 lines

Hi!

Quoted 38 lines
testcases/kernel/syscalls/creat/creat09.c +18 -0
index bed7bddb0..d583cceca 100644
@@ -28,6 +28,16 @@
    *  Date:   Fri Jan 22 16:48:18 2021 -0800
    *
    *  xfs: fix up non-directory creation in SGID directories
+ *
+ * When use acl or umask, it still has bug.
+ *
+ * Fixed in:
+ *
+ *  commit 1639a49ccdce58ea248841ed9b23babcce6dbb0b
+ *  Author: Yang Xu <[email protected]>
+ *  Date:   Thu July 14 14:11:27 2022 +0800
+ *
+ *  fs: move S_ISGID stripping into the vfs_*() helpers
    */
 
   #include <stdlib.h>
@@ -47,6 +57,14 @@
   static gid_t free_gid;
   static int fd = -1;
 
+static struct tcase {
+	const char *msg;
+	int mask;
+} tcases[] = {
+	{"under umask(0) situation", 0},
+	{"under umask(S_IXGRP) situation", S_IXGRP}
+};
+
   static void setup(void)
   {
   	struct stat buf;
@@ -94,8 +112,14 @@ static void file_test(const char *name)
   		tst_res(TPASS, "%s: Setgid bit not set", name);

testcases/kernel/syscalls/creat/creat09.c static void file_test(const char *name) · line 121

Quoted 10 lines
testcases/kernel/syscalls/creat/creat09.c +6 -1
   }
 
-static void run(void)
+static void run(unsigned int n)
   {
+	struct tcase *tc = &tcases[n];
+
+	umask(tc->mask);
+	tst_res(TINFO, "Testing setgid behaviour when creating file %s",
+			tc->msg);

This can be shorter and more to the point, something as:

	tst_res(TINFO, "File created with %s", tc->msg);
Quoted 7 lines
Quoted 5 lines

And the msg could be just "umask(0)" and "umask(S_IXGRP)".

Otherwise it's fine and I can fix the messages before applying if you want.

Yes. Please apply it with fix the messages. Thanks.

I guess you miss this patchset. so ping again.

Best Regards
Yang Xu

Quoted 37 lines

Best Regards
Yang Xu

Quoted 32 lines
Quoted 31 lines
testcases/kernel/syscalls/creat/creat09.c +3 -1
   	fd = SAFE_CREAT(CREAT_FILE, MODE_SGID);
   	SAFE_CLOSE(fd);
   	file_test(CREAT_FILE);
@@ -115,13 +139,14 @@ static void cleanup(void)
   }
 
   static struct tst_test test = {
-	.test_all = run,
+	.test = run,
   	.setup = setup,
   	.cleanup = cleanup,
   	.needs_root = 1,
   	.all_filesystems = 1,
   	.mount_device = 1,
   	.mntpoint = MNTPOINT,
+	.tcnt = ARRAY_SIZE(tcases),
   	.skip_filesystems = (const char*[]) {
   		"exfat",
   		"ntfs",
@@ -132,6 +157,7 @@ static struct tst_test test = {
   		{"linux-git", "0fa3ecd87848"},
   		{"CVE", "2018-13405"},
   		{"linux-git", "01ea173e103e"},
+		{"linux-git", "1639a49ccdce"},
   		{}
   	},
   };
Signature · 1 line
2.23.0
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#15 lore raw

Hi!

Quoted 3 lines
Quoted 1 line

Yes. Please apply it with fix the messages. Thanks.

I guess you miss this patchset. so ping again.

Sorry for the delay.

I just did quick test and I got failures on XFS on kernel 5.19, wasn't this supposed to be fixed in 5.19?

...
creat09.c:106: TPASS: mntpoint/testdir/creat.tmp: Owned by correct group creat09.c:112: TPASS: mntpoint/testdir/creat.tmp: Setgid bit not set creat09.c:106: TPASS: mntpoint/testdir/open.tmp: Owned by correct group creat09.c:112: TPASS: mntpoint/testdir/open.tmp: Setgid bit not set creat09.c:120: TINFO: File created with umask(S_IXGRP) creat09.c:106: TPASS: mntpoint/testdir/creat.tmp: Owned by correct group creat09.c:110: TFAIL: mntpoint/testdir/creat.tmp: Setgid bit is set creat09.c:106: TPASS: mntpoint/testdir/open.tmp: Owned by correct group creat09.c:110: TFAIL: mntpoint/testdir/open.tmp: Setgid bit is set
...

$ uname -r
5.19.0
$ git describe 1639a49ccdce
v5.19-rc7-3-g1639a49ccdce

Is there any in-flight patch for v6.0 that fixes this for XFS?

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#16 lore raw
Quoted 9 lines · Cyril Hrubis

Hi!

Quoted 3 lines
Quoted 1 line

Yes. Please apply it with fix the messages. Thanks.

I guess you miss this patchset. so ping again.

Sorry for the delay.

I just did quick test and I got failures on XFS on kernel 5.19, wasn't this supposed to be fixed in 5.19?

No, this is fixed starting with v6.0-rc1 :)

Quoted 13 lines

...
creat09.c:106: TPASS: mntpoint/testdir/creat.tmp: Owned by correct group creat09.c:112: TPASS: mntpoint/testdir/creat.tmp: Setgid bit not set creat09.c:106: TPASS: mntpoint/testdir/open.tmp: Owned by correct group creat09.c:112: TPASS: mntpoint/testdir/open.tmp: Setgid bit not set creat09.c:120: TINFO: File created with umask(S_IXGRP) creat09.c:106: TPASS: mntpoint/testdir/creat.tmp: Owned by correct group creat09.c:110: TFAIL: mntpoint/testdir/creat.tmp: Setgid bit is set creat09.c:106: TPASS: mntpoint/testdir/open.tmp: Owned by correct group creat09.c:110: TFAIL: mntpoint/testdir/open.tmp: Setgid bit is set
...

Quoted 8 lines
$ uname -r
5.19.0
$ git describe 1639a49ccdce
v5.19-rc7-3-g1639a49ccdce

Is there any in-flight patch for v6.0 that fixes this for XFS?

You're looking for
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=426b4ca2d6a5ab51f6b6175d06e4f8ddea434cdf

Hope this helps!
Christian

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp