Skip to contentSkip to conversation

creat09: Run on all_filesystems

PATCH Superseded Petr Vorel 3 participants 3 messages Oct 15, 2021

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH v2 1/1 creat09: Run on all_filesystems

To make sure bug on XFS is detected on systems which use it.

Due setgid is test problematic on Microsoft filesystems:

creat09.c:81: TBROK: ntfs: Setgid bit not set creat09.c:76: TBROK: chown(exfat,65533,4) failed: EPERM (1) creat09.c:76: TBROK: chown(vfat,65533,4) failed: EPERM (1)

thus they're disabled.

---
Changes v1->v2:
* drop useless code creating directory (reported by Martin Doucha)

 testcases/kernel/syscalls/creat/creat09.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/creat/creat09.c +14 -1
index 681b80c7d..1d6c1643c 100644
@@ -33,13 +33,15 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <pwd.h>
+#include <stdio.h>
 #include "tst_test.h"
 #include "tst_uid.h"
 
 #define MODE_RWX        0777
 #define MODE_SGID       (S_ISGID|0777)
 
-#define WORKDIR		"testdir"
+#define MNTPOINT	"mntpoint"
+#define WORKDIR		MNTPOINT "testdir"
 #define CREAT_FILE	WORKDIR "/creat.tmp"
 #define OPEN_FILE	WORKDIR "/open.tmp"
 
@@ -51,6 +53,8 @@ static void setup(void)
 	struct stat buf;
 	struct passwd *ltpuser = SAFE_GETPWNAM("nobody");
 
+	SAFE_CHDIR(MNTPOINT);
+
 	tst_res(TINFO, "User nobody: uid = %d, gid = %d", (int)ltpuser->pw_uid,
 		(int)ltpuser->pw_gid);
 	free_gid = tst_get_free_gid(ltpuser->pw_gid);
@@ -119,6 +123,15 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.needs_root = 1,
 	.needs_tmpdir = 1,
+	.all_filesystems = 1,
+	.mount_device = 1,
+	.mntpoint = MNTPOINT,
+	.skip_filesystems = (const char*[]) {
+		"exfat",
+		"ntfs",
+		"vfat",
+		NULL
+	},
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "0fa3ecd87848"},
 		{"CVE", "2018-13405"},
Signature · 5 lines
2.33.0


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

Hi Petr

Quoted 26 lines

To make sure bug on XFS is detected on systems which use it.

Due setgid is test problematic on Microsoft filesystems:

creat09.c:81: TBROK: ntfs: Setgid bit not set creat09.c:76: TBROK: chown(exfat,65533,4) failed: EPERM (1) creat09.c:76: TBROK: chown(vfat,65533,4) failed: EPERM (1)

thus they're disabled.

---
Changes v1->v2:
* drop useless code creating directory (reported by Martin Doucha)

  testcases/kernel/syscalls/creat/creat09.c | 15 ++++++++++++++-
  1 file changed, 14 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/creat/creat09.c +0 -0
index 681b80c7d..1d6c1643c 100644
@@ -33,13 +33,15 @@
  #include<stdlib.h>
  #include<sys/types.h>
  #include<pwd.h>

testcases/kernel/syscalls/creat/creat09.c line 44

Quoted 10 lines
testcases/kernel/syscalls/creat/creat09.c +3 -1
+#include<stdio.h>
  #include "tst_test.h"
  #include "tst_uid.h"
 
  #define MODE_RWX        0777
  #define MODE_SGID       (S_ISGID|0777)
 
-#define WORKDIR		"testdir"
+#define MNTPOINT	"mntpoint"
+#define WORKDIR		MNTPOINT "testdir"

You missed "/".

testcases/kernel/syscalls/creat/creat09.c static void setup(void) · line 56

Quoted 8 lines
testcases/kernel/syscalls/creat/creat09.c +1 -0
  #define CREAT_FILE	WORKDIR "/creat.tmp"
  #define OPEN_FILE	WORKDIR "/open.tmp"
 
@@ -51,6 +53,8 @@ static void setup(void)
  	struct stat buf;
  	struct passwd *ltpuser = SAFE_GETPWNAM("nobody");
 
+	SAFE_CHDIR(MNTPOINT);

Why need chdir?

testcases/kernel/syscalls/creat/creat09.c static struct tst_test test = { · line 125

Quoted 8 lines
testcases/kernel/syscalls/creat/creat09.c +1 -0
+
  	tst_res(TINFO, "User nobody: uid = %d, gid = %d", (int)ltpuser->pw_uid,
  		(int)ltpuser->pw_gid);
  	free_gid = tst_get_free_gid(ltpuser->pw_gid);
@@ -119,6 +123,15 @@ static struct tst_test test = {
  	.cleanup = cleanup,
  	.needs_root = 1,
  	.needs_tmpdir = 1,

This can be removed.

Best Regards
Yang Xu

Quoted 12 lines
testcases/kernel/syscalls/creat/creat09.c +9 -0
+	.all_filesystems = 1,
+	.mount_device = 1,
+	.mntpoint = MNTPOINT,
+	.skip_filesystems = (const char*[]) {
+		"exfat",
+		"ntfs",
+		"vfat",
+		NULL
+	},
  	.tags = (const struct tst_tag[]) {
  		{"linux-git", "0fa3ecd87848"},
  		{"CVE", "2018-13405"},
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
Quoted 20 lines · On Fri, Oct 15, 2021 at 9:37 AM [email protected]…

Hi Petr

Quoted 18 lines

To make sure bug on XFS is detected on systems which use it.

Due setgid is test problematic on Microsoft filesystems:

creat09.c:81: TBROK: ntfs: Setgid bit not set creat09.c:76: TBROK: chown(exfat,65533,4) failed: EPERM (1) creat09.c:76: TBROK: chown(vfat,65533,4) failed: EPERM (1)

thus they're disabled.

---
Changes v1->v2:
* drop useless code creating directory (reported by Martin Doucha)

  testcases/kernel/syscalls/creat/creat09.c | 15 ++++++++++++++-
  1 file changed, 14 insertions(+), 1 deletion(-)
Quoted 9 lines

testcases/kernel/syscalls/creat/creat09.c line 36

Quoted 9 lines
testcases/kernel/syscalls/creat/creat09.c +1 -0
index 681b80c7d..1d6c1643c 100644
@@ -33,13 +33,15 @@
  #include<stdlib.h>
  #include<sys/types.h>
  #include<pwd.h>
+#include<stdio.h>

Is this new include still needed?

Quoted 13 lines

testcases/kernel/syscalls/creat/creat09.c line 44

Quoted 9 lines
testcases/kernel/syscalls/creat/creat09.c +2 -1
  #include "tst_test.h"
  #include "tst_uid.h"
 
  #define MODE_RWX        0777
  #define MODE_SGID       (S_ISGID|0777)
 
-#define WORKDIR              "testdir"
+#define MNTPOINT     "mntpoint"
+#define WORKDIR              MNTPOINT "testdir"

You missed "/".

Quoted 3 lines
testcases/kernel/syscalls/creat/creat09.c +0 -0
  #define CREAT_FILE  WORKDIR "/creat.tmp"
  #define OPEN_FILE   WORKDIR "/open.tmp"
 
Quoted 6 lines

testcases/kernel/syscalls/creat/creat09.c static void setup(void) · line 56

Quoted 5 lines
testcases/kernel/syscalls/creat/creat09.c +1 -0
@@ -51,6 +53,8 @@ static void setup(void)
      struct stat buf;
      struct passwd *ltpuser = SAFE_GETPWNAM("nobody");
 
+     SAFE_CHDIR(MNTPOINT);

Why need chdir?

Agreed, either make WORKDIR relative to MNTPOINT and use chdir or add "/" and then chdir can be dropped.

Quoted 9 lines

testcases/kernel/syscalls/creat/creat09.c static struct tst_test test = { · line 125

Quoted 8 lines
testcases/kernel/syscalls/creat/creat09.c +1 -0
+
      tst_res(TINFO, "User nobody: uid = %d, gid = %d", (int)ltpuser->pw_uid,
              (int)ltpuser->pw_gid);
      free_gid = tst_get_free_gid(ltpuser->pw_gid);
@@ -119,6 +123,15 @@ static struct tst_test test = {
      .cleanup = cleanup,
      .needs_root = 1,
      .needs_tmpdir = 1,

This can be removed.

True, since mntpoint implies tmpdir. But for readability I'd keep it, it makes it
more visible that cwd is tmpdir at start of test.

Quoted 19 lines

Best Regards
Yang Xu

testcases/kernel/syscalls/creat/creat09.c static struct tst_test test = { · line 137

Quoted 12 lines
testcases/kernel/syscalls/creat/creat09.c +9 -0
+     .all_filesystems = 1,
+     .mount_device = 1,
+     .mntpoint = MNTPOINT,
+     .skip_filesystems = (const char*[]) {
+             "exfat",
+             "ntfs",
+             "vfat",
+             NULL
+     },
      .tags = (const struct tst_tag[]) {
              {"linux-git", "0fa3ecd87848"},
              {"CVE", "2018-13405"},

--
Mailing list info: https://lists.linux.it/listinfo/ltp

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