[LTP] [PATCH] setfsuid02: using -1 as invalid fsuid for setfsuid()

Richard Palethorpe rpalethorpe@suse.de
Mon Oct 31 14:01:49 CET 2022


Hello,

Avinesh Kumar <akumar@suse.de> writes:

> a uid which does not have an entry in the /etc/passwd
> file is not really an invalid fsuid for setfsuid(), so changing
> the test to use -1 as an invalid fsuid.
> And second setfsuid(-1) call is to verify that preceding call has
> actually failed and there is no change in the fsuid.

I think the original test is flawed and testing what using -1 does is
not very interesting as the kernel uses standard boilerplate to deal
with this.

AFAICT we don't test what happens if a non-root user tries to set the
fsuid to a uid that is not the euid, ruid or saved uid or 0/-1.

Possibly that is something for a new test though.

>
> Signed-off-by: Avinesh Kumar <akumar@suse.de>
> ---
>  testcases/kernel/syscalls/setfsuid/setfsuid02.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/setfsuid/setfsuid02.c b/testcases/kernel/syscalls/setfsuid/setfsuid02.c
> index 850f17834..f5aa1c004 100644
> --- a/testcases/kernel/syscalls/setfsuid/setfsuid02.c
> +++ b/testcases/kernel/syscalls/setfsuid/setfsuid02.c
> @@ -21,9 +21,7 @@ static void run(void)
>  	uid_t invalid_uid, current_uid;
>  
>  	current_uid = geteuid();
> -	invalid_uid = 1;
> -	while (getpwuid(invalid_uid))
> -		invalid_uid++;
> +	invalid_uid = -1;
>  
>  	UID16_CHECK(invalid_uid, setfsuid);
>  
> -- 
> 2.38.0


-- 
Thank you,
Richard.


More information about the ltp mailing list