Bug 1286320 - pcscd generates massive CPU load
pcscd generates massive CPU load
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: coolkey (Show other bugs)
7.2
x86_64 Linux
unspecified Severity medium
: rc
: ---
Assigned To: Bob Relyea
Asha Akkiangady
:
: 1348586 (view as bug list)
Depends On:
Blocks: 1352161
  Show dependency treegraph
 
Reported: 2015-11-27 20:20 EST by mathewm770
Modified: 2017-03-21 15:03 EDT (History)
7 users (show)

See Also:
Fixed In Version: coolkey-1.1.0-35.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1352161 (view as bug list)
Environment:
Last Closed: 2016-11-04 02:52:18 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Bugzilla 1017431 None None None Never
Red Hat Bugzilla 350441 None None None Never

  None (edit)
Description mathewm770 2015-11-27 20:20:56 EST
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:
always

Steps to Reproduce:
1. insert USB smart card (Yubikey NEO)
2. add smartcard key to a new started SSH agent
3. use this key in an ssh session

Actual results:

* pcscd maxes out a CPU core until killed or stopped via systemctl
* laptop battery remaining drops from 11 hours to 2 hours
* system fan runs at full speed

Expected results:

pcscd should not max out a CPU core

Additional info:

This seems to be a really old bug that has been around since at least 2008 but has never really been fixed.

Some probably related examples:

RHBZ #350441
RHBZ #1017431
Comment 1 mathewm770 2015-11-27 20:33:27 EST
Sorry, missed a couple of fields.

Description of problem:
pcscd generates massive CPU load when used with USB smart cards

Version-Release number of selected component (if applicable):
pcsc-lite-1.8.8-6.el7.x86_64
pcsc-lite-ccid-1.4.10-10.el7.x86_64
pcsc-lite-libs-1.8.8-6.el7.x86_64
Comment 2 Mike Jones 2015-12-11 13:04:50 EST
I can produce this issue reliably with a slightly different use-case.
After using the smartcard to access webmail (Firefox), I log out of email, close the browser and then remove the card from the reader. The pcscd process immediately jumps to 170% - 250% in top and stays there.

Putting the smartcard back into the reader causes it to cease immediately.
Then you can make it happen and make it stop by removing and reinserting the card any number of times.

I installed the pcsc-lite debuginfo package and attached gdb while it was in the high CPU state. The problem is in winscard_svc.c around line 363 in the CMD_GET_READERS_STATE case. While the card is removed, there is a hard loop going on here where the RFWaitForReaderInit() and MessageSend() both return very quickly and then the outer while loop iterates again. Nothing in the sequence ever blocks or takes a break, resulting in the high CPU usage.
Comment 5 Radek Duda 2016-06-06 10:05:16 EDT
Related to bug 1343096
Comment 6 John Heidemann 2016-06-22 12:08:14 EDT
This problem seems to also occur on Fedora 24.
I see both pcscd and gnome-settings running at high CPU after a Yubikey NEO is removed.

It looks like ubuntu found it in March:
https://bugs.launchpad.net/ubuntu/+source/pcsc-lite/+bug/1551897

and upstream has a fix (from the Ubuntu bug report):

https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=pcsclite/CCID.git;a=commitdiff_plain;h=3c21f452543983f3625a1965ce234074cbda6865
Comment 7 John Heidemann 2016-06-22 12:35:55 EDT
Not clear the Fedora 24 problem is the same as here.
I opened a fedora ticket as https://bugzilla.redhat.com/show_bug.cgi?id=1349073
Comment 8 Bob Relyea 2016-06-30 18:19:14 EDT
I can simulate this issue with a normal reader by pluging and unpluging the reader with a card inserted.

Start Firefox.
run top
unplug the reader. Not PCSC run to 100% or more of the cpu (depending on the number of cores).

The ubuntu patch is in pcsc-lite-ccid. I've coded a version of that patch, but it doesn't affect RHEL. If there is a second problem we can add that patch to pcsc-lite.

The issue actually appears to be in libcoolkey I've move the component to coolkey to pick up the coolkey fix.
Comment 10 Bob Relyea 2016-07-01 17:12:56 EDT
fixed in coolkey-1.1.0-35.el7
Comment 12 John Heidemann 2016-07-02 18:42:23 EDT
Bob Relyea (or anyone), can you provide a URL to coolkey-1.1.0-35.el7 source in the REHL build system?  (If it's available.)  I would like to see if it addresses bug #1349073.

Also, what specific binary includes libcoolkey?  I don't see either in the ldd list of pcscd or gnome-settings-daemon on either CentOS7 nor on Fedora 24.
Comment 13 Bob Relyea 2016-07-05 15:03:15 EDT
> Bob Relyea (or anyone), can you provide a URL to coolkey-1.1.0-35.el7 source
> in the REHL build system?  (If it's available.)  I would like to see if it
> addresses bug #1349073.

I believe it's still internal until 7.3 is released.


> Also, what specific binary includes libcoolkey?  I don't see either in the ldd
> list of pcscd or gnome-settings-daemon on either CentOS7 nor on Fedora 24.

It won't show up in ldd. It' dlopen'ed as a PKCS #11 module. NSS will open it, so anything that include libnss3.so would potentially use it, but so would certain apps that use openssl (like ssh).

There are several apps that use the WaitForSlotEvent() call, including firefox, thunderbird and esc (the latter, if installed is running as a daemon looking for smart card insertions).

bob
Comment 14 John Heidemann 2016-07-05 19:08:15 EDT
Wrt comment:13: thanks for both comments.  I'll follow-up at bug #1349073.
Comment 15 Roshni 2016-08-03 15:23:09 EDT
Reproduced the issue using coolkey-1.1.0-35.el7

1. Open firefox when reader is inserted
2.  top | grep pcscd
 2797 root      20   0  486256   1840   1300 S   0.3  0.0   0:00.36 pcscd      
 2797 root      20   0  486256   1840   1300 S   0.3  0.0   0:00.37 pcscd      
 2797 root      20   0  481960   1812   1180 S  47.2  0.0   0:01.79 pcscd      
 2797 root      20   0  481960   1812   1180 S 166.4  0.0   0:06.80 pcscd      
 2797 root      20   0  481960   1812   1180 S 164.1  0.0   0:11.74 pcscd      
 2797 root      20   0  481960   1812   1180 S 166.0  0.0   0:16.72 pcscd      
 2797 root      20   0  481960   1812   1180 S 165.4  0.0   0:21.70 pcscd      
 2797 root      20   0  481960   1812   1180 S 164.8  0.0   0:26.66 pcscd      
 2797 root      20   0  481960   1812   1180 S 170.4  0.0   0:31.79 pcscd      
 2797 root      20   0  481960   1812   1180 S 165.8  0.0   0:36.78 pcscd      
 2797 root      20   0  486256   2048   1292 S 108.0  0.0   0:40.02 pcscd      
 2797 root      20   0  486256   2048   1292 S   0.3  0.0   0:40.03 pcscd      
 2797 root      20   0  486256   2048   1292 S   0.3  0.0   0:40.04 pcscd      
 2797 root      20   0  486256   2048   1292 S   0.3  0.0   0:40.05 pcscd

The reader was removed after 0:00:37

Upgraded to:

Name        : coolkey
Version     : 1.1.0
Release     : 35.el7
Architecture: x86_64
Install Date: Wed 03 Aug 2016 03:03:19 PM EDT
Group       : System Environment/Libraries
Size        : 300220
License     : LGPLv2
Signature   : RSA/SHA256, Thu 28 Jul 2016 01:24:44 PM EDT, Key ID 938a80caf21541eb
Source RPM  : coolkey-1.1.0-35.el7.src.rpm
Build Date  : Fri 01 Jul 2016 05:09:30 PM EDT
Build Host  : x86-034.build.eng.bos.redhat.com
Relocations : (not relocatable)
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Vendor      : Red Hat, Inc.
URL         : http://directory.fedora.redhat.com/wiki/CoolKey
Summary     : CoolKey PKCS #11 module

Repeated the steps as above
[rpattath@dhcp129-54 ~]$ top | grep pcscd
 2786 root      20   0  486256   3892   1300 S   0.3  0.0   0:00.34 pcscd      
 2786 root      20   0  486256   3892   1300 S   0.3  0.0   0:00.35 pcscd      
 2786 root      20   0  481960   3864   1180 S   0.7  0.0   0:00.37 pcscd      
 2786 root      20   0  481960   3864   1180 S   0.3  0.0   0:00.38 pcscd      
 2786 root      20   0  481960   3864   1180 S   0.3  0.0   0:00.39 pcscd      
 2786 root      20   0  481960   3864   1180 S   0.3  0.0   0:00.40 pcscd      
 2786 root      20   0  486256   4100   1292 S   0.3  0.1   0:00.41 pcscd      
 2786 root      20   0  486256   4100   1292 S   0.7  0.1   0:00.43 pcscd

The reader was removed after 0:00:35
Comment 17 errata-xmlrpc 2016-11-04 02:52:18 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2465.html
Comment 18 Bob Relyea 2017-03-21 15:03:40 EDT
*** Bug 1348586 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.