[Pcsclite-muscle] Rare race condition in SCardGetStatusChange()

Ludovic Rousseau ludovic.rousseau at gmail.com
Wed Apr 18 11:58:45 PDT 2018


2018-04-17 17:37 GMT+02:00 Maximilian Stein <maximilian.stein at secunet.com>:
> On 17.04.2018 16:42, Ludovic Rousseau wrote:
>>
>> In CMD_WAIT_READER_STATE_CHANGE case you add:
>> +#ifdef USE_USB
>> +                /* wait until all readers are ready */
>> +                RFWaitForReaderInit();
>> +#endif
>>
>> Why?
>
> Because I use CMD_WAIT_READER_STATE_CHANGE to dump the reader states to
> the client (done inside EHRegisterClientForEvent()). So I mindlessly
> copied this behaviour from CMD_GET_READERS_STATE, which was used
> originally by SCardGetStatusChange().

Exact.
I added the call to RFWaitForReaderInit() in
https://salsa.debian.org/rousseau/PCSC/commit/3cf4188c3eee4d7fafaa361adfda0075cdb7a997

The same should be used for CMD_WAIT_READER_STATE_CHANGE for the same reason.

> But thinking about it, there is still a chance that a new reader is
> discovered and not fully initialized exactly while dumping the reader
> states. If this is not a problem, the call to RFWaitForReaderInit()
> could be removed from both CMD_GET_READERS_STATE and
> CMD_WAIT_READER_STATE_CHANGE. Otherwise updating and dumping the reader
> states should maybe be synchronized by a mutex to avoid invalid state
> information.

I described the problem solved by RFWaitForReaderInit() in the patch
commit message.
I am happy to describe the problem a patch is supposed to fix. 7 years
later I am not able to remind why I did what I did.

Your patch looks good.
Thanks

-- 
 Dr. Ludovic Rousseau



More information about the pcsclite-muscle mailing list