Re: [PATCH] async_die_is_recursing: fix use of pthread_getspecific for Fedora

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 3, 2021 at 6:48 PM Victoria Dye via GitGit
> The fix imitates a workaround added in SELinux [2] by using the pointer to
> `ret` as the second argument to `pthread_getspecific`.

the SELinux workaround uses a valid global pointer though; while this won't

> diff --git a/run-command.c b/run-command.c
> index 7ef5cc712a9..a82cf69e7d3 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -1099,7 +1099,7 @@ static NORETURN void die_async(const char *err, va_list params)
>  static int async_die_is_recursing(void)
>  {
>         void *ret = pthread_getspecific(async_die_counter);
> -       pthread_setspecific(async_die_counter, (void *)1);
> +       pthread_setspecific(async_die_counter, &ret); /* set to any non-NULL valid pointer */

I guess this would work, since the pointer is never dereferenced, but
the use of (void *)1 was hacky, and this warning seems like the right
time to make it less so.

Would a dynamically allocated pthread_local variable be a better
option,  or even a static global, since we don't care about its value
so no need to worry about any races?

If neither, would MAP_FAILED also trigger the warning?

Carlo



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux