<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Sep 17, 2014 at 2:34 PM, Sebastien Lorquet <span dir="ltr"><<a href="mailto:sebastien@lorquet.fr" target="_blank">sebastien@lorquet.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
The evil process might block access to the reader, but in that case, the<br>
legitimate process will likely timeout while waiting for the card</blockquote><div>Not true if timeout = INFINITE<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">, and this can<br>
be the occasion to ask the user to "remove and reinsert" the card, which may<br>
help the legitimate process to gain access to the card.<br>
<br>
The evil process can still try transactions in a loop, so my idea does not<br>
guarantee that the legitimate process will access the card in presence of an<br>
attacker.<br>
<br>
However common situations do not involve really "evil" processes, but rather<br>
daemons that forget to release the card, so the "remove/reinsert" trick does help.<br></blockquote><div>I have seen<br> while(1){<br> SCardConnect(exclusive)...<br> }<br></div><div>in some smartcard applications. Thats EVIL! xD<br><br></div><br>Le 17/09/2014 14:23, Ludovic Rousseau a écrit :<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5">> 2014-09-17 11:58 GMT+02:00 helpcrypto helpcrypto <<a href="mailto:helpcrypto@gmail.com">helpcrypto@gmail.com</a>>:<br>
>> On Mon, Sep 15, 2014 at 6:43 PM, Ludovic Rousseau<br>
>> <<a href="mailto:ludovic.rousseau@gmail.com">ludovic.rousseau@gmail.com</a>> wrote:<br>
>>><br>
>>><br>
>>> Please, please do NOT use a loop of proposed by Bruno Jesus.<br>
>>> I invested a lot of time in removing all polling loops in pcsc-lite<br>
>>> and the CCID driver. So please do not add a polling loop in your<br>
>>> application when you can do without one.<br>
>><br>
>><br>
>> Talking about this, Ludovic, I'll like to ask you:<br>
>><br>
>> IIUC, using SHARED + BeginTransaction/EndTransaction could lead to<br>
>> starvation:<br>
>><br>
>> Process A opens a shared connection and invokes beginTransaction<br>
>> Process B opens a shared connection and invokes beginTransaction (blocked)<br>
>> If evil process A never releases transaction, B will starve<br>
><br>
> Yes. This is the expected behaviour.<br>
><br>
>> A "complex" father-child process will be needed to detect if process B is<br>
>> being blocked to be able to resume, right?<br>
><br>
> To resume what?<br>
><br></div></div></blockquote><div>To let application B know
someone else is using the resource, and even query the system if the
resource is abandonded or still in use.<br><br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5">
>> Using EXCLUSIVE with retry-loop seems to be better:<br>
>> Process A opens an exclusive connection<br>
>> Process B try to open an exclusive connection and fails (now it is aware of<br>
>> other process using SC)<br>
>> process B could retry a few times, or even detect if its a deadlock<br>
>> (process A died before releasing the connection)<br>
>> Am I right?<br>
><br>
> No.<br>
> If A dies then the lock will be released automatically. If that does<br>
> not occur then it is a bug in pcsc-lite and you should report it.<br></div></div></blockquote><div><div>What locking system are you using? Flock? Mutex? <br></div>Can you link any source where using it? I'm very interested in this!<br><br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5">
>> Said so: are exclusive connections better in a non-controlled/evil<br>
>> applications environment?<br>
><br>
> It is the application choice to share or not the reader.<br>
><br>
> Once application A (evil or not) has an exclusive access to the reader<br>
> then application B can just wait.<br>
><br>
> PC/SC has not been designed to give a fair access to the smart card to<br>
> all the running applications.<br></div></div></blockquote><div>Sure!<br><br><br></div><div>I just wanted just to know your opinion about this.<br></div><div>Thanks!<br></div></div><br></div></div>