[SSSD] sss_client: thread safe initialisation of sss_nss_mc_get_ctx
Sumit Bose
sbose at redhat.com
Wed Jul 16 12:02:40 UTC 2014
On Wed, Jul 16, 2014 at 11:32:53AM +0200, Lukas Slebodnik wrote:
> ehlo,
>
> attached patches fix problems with mmap cache in client code.
> The 1st patch is at least 5th version, because I found few problems in my
> previous versions myself. I hope you will not find anything else :-)
>
> Patches change client code. It will be good to have at least 2 ACKs.
Currently we use sss_nss_lock() and sss_nss_unlock() to protect
sss_nss_make_request() in multi-threaded clients (there is sss_pam_lock()
and sss_pam_lock() for pam_sss as well). I wonder if a new pair like
sss_mc_init_lock() sss_mc_init_unlock() might help to protect
sss_nss_mc_get_ctx() as well?
bye,
Sumit
>
> How to test?
> You can use simple program form ticket description #2380.
> Program call getuid, therefore user should be from sssd and not /etc/passwd.
> It needn't crash at first time, but you can use simple for loop
> for i in {1..100}; do ./a1; done
>
> You can also use 3th patch to see code flow. e.g.
>
> bash-4.2$ ./a1
> more [2] threads try to init mem ctc
> init.done
> seed or table size do not match
> sss_nss_check_header end:Invalid argument
> more [3] threads try to init mem ctc
> calling munmap
> calling close
> Segmentation fault (core dumped)
>
>
> bash-4.2$ ./a1
> init.done
> more [2] threads try to init mem ctc
> more [3] threads try to init mem ctc
> seed or table size do not match
> sss_nss_check_header end:Invalid argument
> seed or table size do not match
> seed or table size do not match
> calling munmap
> calling close
> sss_nss_check_header beg:Invalid argument
> calling close
> init.done
> Floating point exception (core dumped)
>
> If you apply 3rd patch you can simulate old version with simple diff
> diff --git a/src/sss_client/nss_mc_common.c b/src/sss_client/nss_mc_common.c
> index 768763f..cea3a78 100644
> --- a/src/sss_client/nss_mc_common.c
> +++ b/src/sss_client/nss_mc_common.c
> @@ -131,7 +131,7 @@ errno_t sss_nss_mc_get_ctx(const char *name, struct sss_cli_mc_ctx *ctx)
> */
> fprintf(stderr, "more [%d] threads try to init mem ctc\n",
> ctx->init_count);
> - return EAGAIN;
> + //return EAGAIN;
> }
>
> ret = asprintf(&file, "%s/%s", SSS_NSS_MCACHE_DIR, name);
>
> LS
More information about the sssd-devel
mailing list