[PATCH] nptl: Use SA_RESTART for SIGCANCEL handler

Adhemerval Zanella adhemerval.zanella@linaro.org
Tue Jun 22 19:50:09 GMT 2021



On 22/06/2021 15:52, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> On 22/06/2021 15:33, Florian Weimer wrote:
>>> * Adhemerval Zanella:
>>>
>>>> On 18/06/2021 08:38, Florian Weimer wrote:
>>>>> * Adhemerval Zanella via Libc-alpha:
>>>>>
>>>>>> The usage of signals to implementation pthread cancellation is an
>>>>>> implementation detail and should not be visible through cancellation
>>>>>> entrypoints.
>>>>>>
>>>>>> However now that pthread_cancel always send the SIGCANCEL, some
>>>>>> entrypoint might be interruptable and return EINTR to the caller
>>>>>> (for instance on sem_wait).
>>>>>>
>>>>>> Using SA_RESTART hides this, since the cancellation handler should
>>>>>> either act uppon cancellation (if asynchronous cancellation is enable)
>>>>>> or ignore the cancellation internal signal.
>>>>>
>>>>> I think this still needs a NEWS entry because there have been kernel
>>>>> bugs in this area (e.g. in CIFS).
>>>>
>>>> Ok, I have added the following on "Deprecated and removed features, and 
>>>> other changes affecting compatibility"
>>>>
>>>> * The pthread cancellation handler is now setup with SA_RESTART.  It should
>>>>   not be visible to application since the cancellation handler should either 
>>>>   act uppon cancellation (if asynchronous cancellation is enabled) or
>>>>   ignore the cancellation internal signal.
>>>
>>> The key change is: The cancellation signal is now sent in more cases,
>>> but this should be transparent to the application due to SA_RESTART.
>>
>> I am not sure if we really need to describe this implementation detail
>> on a NEWS entry.
> 
> It's the cause of additional EINTR errors.  People who have that buggy
> CIFS module and use thread cancellation could see those spurious EINTR
> errors.  Right, without mentioning EINTR it is probably not useful. 8-/

What about:

* The pthread cancellation handler is now installed with SA_RESTART
  and pthread_cancel will always send the internal SIGCANCEL on a
  cancellation request.  It should not be visible to application since 
  the cancellation handler should either act upon cancellation (if 
  asynchronous cancellation is enabled) or ignore the cancellation 
  internal signal.  However there is buggy kernel interfaces (for
  instance some CIFS modules) that could still see spurious EINTR
  error when cancellation interrupts a blocking syscall.


More information about the Libc-alpha mailing list