public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] chdir01: Fix on more restrictive umask
@ 2022-01-11 10:36 Cyril Hrubis
  2022-01-11 12:41 ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2022-01-11 10:36 UTC (permalink / raw)
  To: ltp

Fixes the test on more restrictive umask, this was found on FIPS but
it's not limited to the FIPS system at all. All that is needed to
reproduce the problem is to set umask to 077 before the test is
executed.

The troublemaker here is the FAT filesystem since there are no access
bits defined in FAT disk format and they are emulated completely by the
kernel. This means that all files on FAT filesytem have access bits
generated by the kernel accordingly to system umask at the time the
filesystem was mounted. This means that in order to be able to access
the files on FAT we have to set the umask(0) before we mount the
filesystem.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/syscalls/chdir/chdir01.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/chdir/chdir01.c b/testcases/kernel/syscalls/chdir/chdir01.c
index aa25adf6a..c7902376d 100644
--- a/testcases/kernel/syscalls/chdir/chdir01.c
+++ b/testcases/kernel/syscalls/chdir/chdir01.c
@@ -50,16 +50,18 @@ static void setup(void)
 	int fd;
 	struct stat statbuf;
 
+	umask(0);
+
+	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
+
 	cwd = SAFE_GETCWD(NULL, 0);
 	workdir = SAFE_MALLOC(strlen(cwd) + strlen(MNTPOINT) + 2);
 	sprintf(workdir, "%s/%s", cwd, MNTPOINT);
 	free(cwd);
 	SAFE_CHDIR(workdir);
 
-	mode_t sys_umask = umask(0);
 	SAFE_MKDIR(DIR_NAME, 0755);
 	SAFE_MKDIR(BLOCKED_NAME, 0644);
-	umask(sys_umask);
 
 	/* FAT and NTFS override file and directory permissions */
 	SAFE_STAT(BLOCKED_NAME, &statbuf);
@@ -132,12 +134,14 @@ static void run(unsigned int n)
 
 static void cleanup(void)
 {
+	SAFE_CHDIR("..");
+	tst_umount(workdir);
 	free(workdir);
 }
 
 static struct tst_test test = {
 	.needs_root = 1,
-	.mount_device = 1,
+	.format_device = 1,
 	.mntpoint = MNTPOINT,
 	.all_filesystems = 1,
 	.test = run,
-- 
2.34.1


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

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

* Re: [LTP] [PATCH] chdir01: Fix on more restrictive umask
  2022-01-11 10:36 [LTP] [PATCH] chdir01: Fix on more restrictive umask Cyril Hrubis
@ 2022-01-11 12:41 ` Petr Vorel
  2022-01-12 10:01   ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2022-01-11 12:41 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril,

thanks a lot for this fix!
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Tested-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH] chdir01: Fix on more restrictive umask
  2022-01-11 12:41 ` Petr Vorel
@ 2022-01-12 10:01   ` Cyril Hrubis
  0 siblings, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2022-01-12 10:01 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi!
Pushed, thanks for the review and testing.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

end of thread, other threads:[~2022-01-12  9:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-11 10:36 [LTP] [PATCH] chdir01: Fix on more restrictive umask Cyril Hrubis
2022-01-11 12:41 ` Petr Vorel
2022-01-12 10:01   ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox