In select_application function, we can minimize the holding W-lock.
- Queries
- All Stories
- Search
- Advanced Search
- Transactions
- Transaction Logs
Advanced Search
Mon, Nov 18
This may requires major changes for scdaemon.
For the cancelling operation, each card reader access should have an independent resource manager context.
Currently, a single pcsc.contex is shared by all reader accesses.
Hard lockup should be avoided. In particular, following conditions should meet:
- gpgconf --kill scdaemon can kill scdaemon
- KEYINFO requests can be answered for other connections of scdaemon
As of 2024-11-18, my hypothesis is:
- there are some sort of race conditions between PC/SC + card reader (or its driver) + smartcard + scdaemon on Windows, at least at initial use after boot
- because of this, SCardConnect of PC/SC call wrongly fails (somehow confirmed by @ebo's experiments + @gniibe's speculation), or wrongly never returns (@gniibe's guess, side info: its slowness is observed in T7400).
@ebo Thank you for your testing.
Sat, Nov 16
@ikloecker indeed we try only for 5 seconds:
Fri, Nov 15
I think that the card reader is not connected and there is no Scardsvr at this time.
And the card reader connection to USB port results invoking Scardsvr. Then, "SCD SERIALNO --all" gets success.
For T6567 I changed the way that Kleopatra runs "gpgconf --launch gpg-agent". This change is not yet in Eva's test build. It seems my change is not good because running "gpgconf --launch gpg-agent" timed out after 5 seconds in 3 of 3 tests starting Kleopatra after a reboot of the VM. To check if "gpgconf --launch gpg-agent" really takes that long I measured the time in PowerShell after another reboot of the VM. The result is shocking.
Please note that a card insertion to a card reader and a card reader connection to PC are different things.
It may cause different results.
ebo: Thank you for your testing.
Thu, Nov 14
I believe this is a case of non-consumption of client, I had two cards connected, one Yubikey and one Netkey3.0 card.
Setup: I rebooted windows and started Kleopatra. Nothing else.
I put "scd" tag and let me claim this ticket.
Wed, Nov 13
FWIW, we should eventually get rid of the pipe + socket style connection model. It is just to complex with no real benefit.
After fixing two bugs, I changed the title to express the scope of this ticket.
Wed, Nov 6
I found a problem of possible duplicate registration of another APP, due to no serialization for CARD access.
The resource leak was fixed in: rG40707c8bff49: agent: Fix resource leak for PRIMARY_CTX.
Tue, Nov 5
Tue, Oct 29
You should use gpg-agent's integrated ssh-agent. It is anyway much more convenient. I'll move this task to gnupg26, though.
Oct 21 2024
I found fd resource leak in gpg-agent.
- gpg-connect-agent "scd killscd" /bye seems not release a file descriptor somewhere
Oct 10 2024
Oct 9 2024
But the DEVINFO --watch is required to trigger this hang? Kleopatra does not use this but we see simlar hangs from time to time in the current version.
Oct 4 2024
Porting to 2.2 was straightforward - we won't give it an extra QA run.
Oct 1 2024
Fixed in master: rGe7891225788a: gpg: Robust error handling for SCD READKEY.
Sep 30 2024
Some would say it is a bug if keys are not shown - even if the algo is not known ;-)
scdaemon in this case was a broken experiment of mine (trying to see if I can get SoftHSM to work as the OpenPGP card). So this was not a normal, released scdaemon code.
Sep 28 2024
Please send an excerpt from the scdaemon debug output to evaluate why you get somewhat strange looking data. Is this an experimental card? 0xa5 is a common test pattern.
Sep 27 2024
With no scd-event script, it might improve the situation
Sep 25 2024
Sep 20 2024
The change of spawn functions (basically, it was factored out to libgpg-error) results more possibilities to have blocked scdaemon, since the implementation in libgpg-error introduced context switch points when it spawns a child process.
Found another thinko; When there is no clients with DEVINFO --watch, the pipe to be notified is not consumed at all (no read). It eventually results blocked by write(2), when the pipe is filled.
Sep 19 2024
I don’t think I have any other client that would invoke SCD DEVINFO --watch.
Do you have scd-event script in your GNUPGHOME?
I see. the systemd race of having two gpg-agent processes. The second gpg-agent should eventually go away but than it is already too late.
I mean: two gpg-agent requests simultaneously running DEVINFO --watch.
Single scdaemon, two threads handling DEVINFO --watch simultaneously, by pselect + read.
Two threads waken up, but it was only one thread which can read(2), another was blocked (before the fix).
Sep 18 2024
You mean it is possible that the initialization function is called by several threads - or that two scdaemon's are running before they realize that one of them is in the way?
For POSIX, I found an issue of T7151.
If you are using multiple clients which invoke SCD DEVINFO --watch, the problem should be fixed.
If it's not the case, let us locate a bug (or two).
I realized that I put a bug on POSIX; When multiple clients do DEVINFO --watch, it is possible for scdaemon to hang (waiting pselect and read, read by one, read by another is blocked).
Sep 16 2024
Sep 15 2024
Actually we have similar problems with the 2.4 branch - in particular on Windows. We can quite easy reproduce this when using Kleopatra. Thus the working hypothesis is a locking problem because Kleopatra uses several threads and the order of actions recently changed.
Sep 14 2024
Sep 3 2024
Aug 28 2024
So we need a way to launch scdaemon via userv and make sure that the scdaemon user gives proper permissions to its socket file. gpg-agent also nees to check for a proper version of scdaemon and gpgme needs to be aware of this as well (if it want to directly connect to scdaemon).
Jul 5 2024
Jul 1 2024
Jun 27 2024
Asking a change of gpgme would need more time... So, I decided to change gpg-agent side.
gpg-agent part was done in: rGb3f1f2cd192b: agent: Handle SCD DEVINFO --watch command in a special way.
Jun 25 2024
scdaemon part was done in: rG36d8cffc6cd2: scd: Finish DEVINFO --watch command on input close.
Jun 24 2024
Maybe we can support this directly in gpgme's assuan API.
Did some experiment and I concluded (for now) that new command for gpg-agent would not be needed.
Instead, it might be better doing following in GPGME.
Jun 21 2024
Jun 17 2024
May 31 2024
Thanks for your answer, @werner
Do not use the pcscd but the integrated CCID driver. This is actually the default form Unix. Or are you on Windows?
Hello all. I think I am affected by this problem (I get asked for the yubikey PIV pin every time I make a git commit).
Is there a known workaround?
May 17 2024
May 16 2024
Pushed the fix: rGbb57c808b2ad: scd:openpgp: Fix PIN pin2hash_if_kdf.
Apr 23 2024
Apr 22 2024
Applied to 2.4 branch.
Apr 15 2024
@mwalle Thank you for your testing.
Applied to master.
After testing, I'll also apply to 2.4 branch.
Apr 12 2024
FWIW, I've tested this patch and it works fine with both KDF as a constructed tag and as a primitive tag.
I'm considering applying the following patch. With this change, scdaemon will works well with a card implementation which consider F9 (wrongly) as primitive data object, as well as correct card implementation.
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c index 26ac91ea2..09223ce33 100644 --- a/scd/app-openpgp.c +++ b/scd/app-openpgp.c @@ -410,6 +410,10 @@ get_cached_data (app_t app, int tag, size_t len; struct cache_s *c; int exmode; + int do_constructed = 0; + + if ((tag < 0x0100 && (tag & 0x20)) || (tag >= 0x0100 && (tag & 0x2000))) + do_constructed = 1;
Apr 9 2024
Mar 28 2024
Please keep also in mind that the OpenPGP card specification has always and is still developed along with GnuPG . Thus if there are any uncertainties in the specification GnuPG's way of handling thing is the way to go. If there is a way to chnage things without risking any breakage we can of course fix that. In all other cases we need to continue wit the current way. For larger changes in the spec we can of course cleanup stuff - Achim is currently reworking on a revision.
Please keep in mind, that it is not only about GnuPG and the OpenPGP card, but also between GnuPG and other PGP applications. I'm not really sure what the recent commit is doing, if it only affect the reading or also the writing of the data. But IMHO GnuPG should stick to the standard also if writing the KDF DO data because eventually, it will be used for authentication with the card.
Mar 27 2024
Given the situation where GnuPG works well with existing OpenPGP card implementations, what we should do here is, perhaps:
There are multiple problems described in your report. Let us handle one by one.
Mar 26 2024
Mar 13 2024
But only if you can figure out in a transaction or locked sytate whether the card needs a verify. Otherwise we have a race between changing the PIN and verifying a PIN.
This rejection could be relaxed.