[LTP] [PATCH 09/18] kill05: fix race on getpwnam

Cyril Hrubis chrubis@suse.cz
Tue Oct 31 13:01:44 CET 2017


Hi!
> Two threads doing getpwnam to a static struct in the library, sometimes
> end up using the same UID. Fix this.

Hmm these getpwnam() calls are done from different processes, so I
suppose that this happens on uClinux, or do I miss something?

Also we should move these calls to the test setup anyways.

> Reported-by: Tony Thompson <anthony.thompson@arm.com>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
> ---
>  testcases/kernel/syscalls/kill/kill05.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/kill/kill05.c b/testcases/kernel/syscalls/kill/kill05.c
> index ccef5afd6..2ae046130 100644
> --- a/testcases/kernel/syscalls/kill/kill05.c
> +++ b/testcases/kernel/syscalls/kill/kill05.c
> @@ -174,15 +174,16 @@ void do_master_child(char **av)
>  		do_child();
>  #endif
>  	}
> +
> +	/* wait until child sets its euid (and has finished with the static getpwnam result struct) */
> +	wait_for_flag(1);
> +
>  	ltpuser2 = SAFE_GETPWNAM(NULL, user2name);
>  	if (setreuid(ltpuser2->pw_uid, ltpuser2->pw_uid) == -1) {
>  		perror("seteuid failed");
>  		exit(1);
>  	}
>  
> -	/* wait until child sets its euid */
> -	wait_for_flag(1);
> -
>  	TEST(kill(pid1, TEST_SIG));
>  
>  	/* signal the child that we're done */
> -- 
> 2.14.2
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list