[LTP] [PATCH v3 0/2] mount03: Convert to new API

Petr Vorel pvorel@suse.cz
Tue Aug 16 13:49:54 CEST 2022


Hi Xu,

...
> > +++ testcases/kernel/syscalls/mount/mount03.c
...
> >   #define FILE_MODE	0644
> >   #define SUID_MODE	0511
Good catch, SUID_MODE must be 04511.

> Here SUID_MODE miss S_ISUID, that is why this case also pass if we 
> execute a program on filesystem that not mounted with nosuid option.
@Cyril any idea what's wrong here? (not yet tested on tst_reinit()).

> Also, it seems make check code has problem when detecting S_ISUID
Indeed.

> Symbolic permissions 'S_IRUSR|S_IXUSR|S_IXGRP|S_IXOTH' are not 
> preferred. Consider using octal permissions '0511'.
This already been implemented.

> Since we have converted mount03 into new api, mount03_setuid_test.c 
> should also be converted into new spdx.
Planning to, with other required fixes (C API pointed out by Cyril).

> Best Regards
> Yang Xu

> > @@ -74,12 +75,18 @@ static void test_nosuid(void)
> >   {
> >   	pid_t pid;
> >   	int status;
> > +	struct stat st;
> > +
> > +	SAFE_CP(TESTBIN, BIN_PATH);
> > +	SAFE_STAT(BIN_PATH, &st);
> > +	if (st.st_mode != SUID_MODE)
> > +		SAFE_CHMOD(BIN_PATH, SUID_MODE);

> >   	pid = SAFE_FORK();
> >   	if (!pid) {
> >   		SAFE_SETGID(nobody_gid);
> >   		SAFE_SETREUID(-1, nobody_uid);
> > -		SAFE_EXECLP(TESTBIN, TESTBIN, NULL);
> > +		SAFE_EXECL(BIN_PATH, TESTBIN, NULL);
> >   	}

> >   	SAFE_WAITPID(pid, &status, 0);
> > @@ -137,18 +144,10 @@ static struct tcase {

> >   static void setup(void)
> >   {
> > -	struct stat st;
> >   	struct passwd *ltpuser = SAFE_GETPWNAM("nobody");

> >   	nobody_uid = ltpuser->pw_uid;
> >   	nobody_gid = ltpuser->pw_gid;
> > -
> > -	snprintf(file, PATH_MAX, "%s/%s", MNTPOINT, TESTBIN);
> > -	SAFE_CP(TESTBIN, file);
> > -
> > -	SAFE_STAT(file, &st);
> > -	if (st.st_mode != SUID_MODE)
> > -	    SAFE_CHMOD(file, SUID_MODE);
> >   }

> >   static void cleanup(void)


More information about the ltp mailing list