[LTP] [RFC PATCH 1/1] creat09: Fix on more restrictive umask

xuyang2018.jy@fujitsu.com xuyang2018.jy@fujitsu.com
Fri Mar 18 08:59:01 CET 2022


Hi Petr

It fails because the create file without S_IXGRP mode, then we miss 
remove S_ISGID[1] bit.

But I don't known why other filesystem doesn't have this problem.

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/inode.c#n2249

Best Regards
Yang Xu
> XFS fails on umask 0077:
>
> tst_test.c:1528: TINFO: Testing on xfs
> tst_test.c:997: TINFO: Formatting /dev/loop0 with xfs opts='' extra opts=''
> tst_test.c:1458: TINFO: Timeout per run is 0h 05m 00s
> creat09.c:61: TINFO: User nobody: uid = 65534, gid = 65534
> creat09.c:62: TINFO: Found unused GID 3: SUCCESS (0)
> creat09.c:93: TPASS: mntpoint/testdir/creat.tmp: Owned by correct group
> creat09.c:97: TFAIL: mntpoint/testdir/creat.tmp: Setgid bit is set
> creat09.c:93: TPASS: mntpoint/testdir/open.tmp: Owned by correct group
> creat09.c:97: TFAIL: mntpoint/testdir/open.tmp: Setgid bit is set
>
> Thus clear the default umask.
>
> Signed-off-by: Petr Vorel<pvorel@suse.cz>
> ---
>   testcases/kernel/syscalls/creat/creat09.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/testcases/kernel/syscalls/creat/creat09.c b/testcases/kernel/syscalls/creat/creat09.c
> index bed7bddb0e..70da7d2fc7 100644
> --- a/testcases/kernel/syscalls/creat/creat09.c
> +++ b/testcases/kernel/syscalls/creat/creat09.c
> @@ -56,6 +56,8 @@ static void setup(void)
>   		(int)ltpuser->pw_gid);
>   	free_gid = tst_get_free_gid(ltpuser->pw_gid);
>
> +	umask(0);
> +
>   	/* Create directories and set permissions */
>   	SAFE_MKDIR(WORKDIR, MODE_RWX);
>   	SAFE_CHOWN(WORKDIR, ltpuser->pw_uid, free_gid);


More information about the ltp mailing list