Giter Club home page Giter Club logo

Comments (29)

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

See https://ccid.apdu.fr/#support

from pcsc.

jrobsonchase avatar jrobsonchase commented on July 23, 2024

CCID Driver version: 1.4.30
/usr/sbin/pcscd --version:

pcsc-lite version 1.8.24.
Copyright (C) 1999-2002 by David Corcoran <[email protected]>.
Copyright (C) 2001-2015 by Ludovic Rousseau <[email protected]>.
Copyright (C) 2003-2004 by Damien Sauveron <[email protected]>.
Report bugs to <[email protected]>.
Enabled features: Linux x86_64-pc-linux-gnu libsystemd serial usb libudev usbdropdir=/usr/lib/pcsc/drivers ipcdir=/run/pcscd filter configdir=/etc/reader.conf.d

Hardware: Lenovo Thinkpad T470s

Card/reader: Yubikey 5C, Firmware version 5.1.2

Full log:
log.txt

Initial state: pcscd not running, yubikey not plugged in
Sequence of events generating log:

  • Started pcscd via sudo LIBCCID_ifdLogLevel=0x000F pcscd --foreground --debug --apdu --color | tee log.txt
  • Ran pcsc_scan
  • Plugged in yubikey
  • Ran pcsc_scan
  • Unplugged yubikey
  • Ran pcsc_scan
  • Plugged yubikey back in
  • Ran pcsc_scan
  • Ran ykman oath codes (what I'm actually trying to make work)
  • Stopped pcscd

from pcsc.

jrobsonchase avatar jrobsonchase commented on July 23, 2024

Minor update: Yubikey Neo (USB-A) behaves the exact same way if connected via a USB-C adapter, but only if the connection is changed at the USB-C end. If the USB-A portion is connected/disconnected, it behaves as expected.

Maybe some USB-C hotplug issue?

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

What is very strange is that your device is always at /dev/bus/usb/003/002 even after a unplug + replug. The last number should always increase for new USB device.
I suspect a bug in the Linux kernel USB layer.

Try this:

  • connect your yubikey
  • run lsusb
  • remove the yubikey
  • run lsusb
  • connect your yubikey
  • run lsusb

Send me the results of the 3 lsusb executions.

from pcsc.

jrobsonchase avatar jrobsonchase commented on July 23, 2024

lsusb:

jchase@atlas ~ $ lsusb # not connected
Bus 002 Device 002: ID 0bda:0316 Realtek Semiconductor Corp. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 5986:111c Acer, Inc 
Bus 001 Device 002: ID 8087:0a2b Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
jchase@atlas ~ $ lsusb # connected
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 1050:0407 Yubico.com Yubikey 4 OTP+U2F+CCID
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 0bda:0316 Realtek Semiconductor Corp. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 5986:111c Acer, Inc 
Bus 001 Device 002: ID 8087:0a2b Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
jchase@atlas ~ $ lsusb # not connected
Bus 002 Device 002: ID 0bda:0316 Realtek Semiconductor Corp. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 5986:111c Acer, Inc 
Bus 001 Device 002: ID 8087:0a2b Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
jchase@atlas ~ $ lsusb # connected
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 1050:0407 Yubico.com Yubikey 4 OTP+U2F+CCID
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 0bda:0316 Realtek Semiconductor Corp. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 5986:111c Acer, Inc 
Bus 001 Device 002: ID 8087:0a2b Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Also, just for fun:
dmesg.txt

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

The device number should increase for any new USB device.
In your case the device number is again 002. You can try to reproduce the problem with a USB-A port to see the difference.

As I wrote I suspect a problem with USB-C in the Linux kernel. Or maybe your PC firmware.

from pcsc.

jrobsonchase avatar jrobsonchase commented on July 23, 2024

The device number should increase for any new USB device.

Is that also the case when the USB device is connected to a PCI USB controller that's also getting connected/disconnected? Because that's how my USB-C devices seem to behave - both my Yubikey 5C and my C-to-A adapter.

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

I checked with my Yubikey 4 OTP+U2F+CCID on a USB-C port.
First connection:

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046a:00a4 Cherry GmbH 
Bus 001 Device 003: ID 1bcf:0005 Sunplus Innovation Technology Inc. Optical Mouse
Bus 001 Device 005: ID 1050:0407 Yubico.com Yubikey 4 OTP+U2F+CCID
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Second connection:

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046a:00a4 Cherry GmbH 
Bus 001 Device 003: ID 1bcf:0005 Sunplus Innovation Technology Inc. Optical Mouse
Bus 001 Device 006: ID 1050:0407 Yubico.com Yubikey 4 OTP+U2F+CCID
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The Device number changed from 5 to 6.

From your kernel log file I do not like the lines:

[63933.588832] pci 0000:01:00.0: BAR 13: no space for [io  size 0x3000]
[63933.588837] pci 0000:01:00.0: BAR 13: failed to assign [io  size 0x3000]```

from pcsc.

jrobsonchase avatar jrobsonchase commented on July 23, 2024

They Yubikey 4 is a USB-A device, correct? So you're using a USB-C adapter? What connection are you actually changing? If it's the Yubikey-Adapter connection, then my Neo behaves the same way. It's when the adapter (which shows up as a PCI USB controller) is unplugged that the bus itself goes away and all device numbers start back at 1 when it's plugged back in. Is that expected behavior?

from pcsc.

jrobsonchase avatar jrobsonchase commented on July 23, 2024

Oh, I see that there is a Yubikey 4C. If that's the case, is it possible that it's using the legacy USB-C configuration and not acting as a PCI USB controller like the 5C is?

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

Apply this patch:

--- /tmp/sn6adU_hotplug_libudev.c   2019-03-10 22:16:19.624623740 +0100
+++ src/hotplug_libudev.c   2019-03-10 22:16:18.312607387 +0100
@@ -359,6 +359,7 @@ static void HPRemoveDevice(struct udev_d
        return;
    }
 
+   Log3(PCSC_LOG_INFO, "Removing: %s %s", devpath, sysname);
    for (i=0; i<PCSCLITE_MAX_READERS_CONTEXTS; i++)
    {
        if (readerTracker[i].fullName && !strcmp(sysname, readerTracker[i].sysname))

Generate a new pcscd log with inserting and removing your device..

from pcsc.

jrobsonchase avatar jrobsonchase commented on July 23, 2024

New log: log.txt

However, it's never actually getting to the point where it hits that log message. It's returning from HPRemoveDevice at

if (!parent)
    return;

Patch w/ log invocation:

diff --git a/src/hotplug_libudev.c b/src/hotplug_libudev.c
index 25bd408..505b6c3 100644
--- a/src/hotplug_libudev.c
+++ b/src/hotplug_libudev.c
@@ -341,8 +341,10 @@ static void HPRemoveDevice(struct udev_device *dev)
           tree, but the function will find it.*/
        parent = udev_device_get_parent_with_subsystem_devtype(dev, "usb",
                "usb_device");
-       if (!parent)
+       if (!parent) {
+               Log1(PCSC_LOG_INFO, "USB Device parent is NULL.");
                return;
+       }
 
        devpath = udev_device_get_devnode(parent);
        if (!devpath)
@@ -359,6 +361,7 @@ static void HPRemoveDevice(struct udev_device *dev)
                return;
        }
 
+       Log3(PCSC_LOG_INFO, "Removing: %s %s", devpath, sysname);
        for (i=0; i<PCSCLITE_MAX_READERS_CONTEXTS; i++)
        {
                if (readerTracker[i].fullName && !strcmp(sysname, readerTracker[i].sysname))

Resulting log:
log.txt

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

Very interesting. I think you found the cause of issue.
But I have no idea how to fix it now.

I will try to contact Yubico to get a yubikey 5c so I can debug on my side.
Do you confirm you are using this "YubiKey 5C Nano" https://www.yubico.com/product/yubikey-5c-nano/#yubikey-5c-nano ?

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

It is strange that 2 new USB bus are created when you connect the Yubikey device:

Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The Yubikey then appears on bus 003

Bus 003 Device 002: ID 1050:0407 Yubico.com Yubikey 4 OTP+U2F+CCID
  1. What is the bus 004? Where does it comes from?
  2. Do you have a special configuration for your USB-C port? Is it on the mother board? or a child board?
  3. Can you run connect the USB-A to USB-C adapter but with no USB-A device connect and run lsusb?

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

I got a YubiKey 5C. I can't reproduce your problem.
Without the YubiKey:

$ lsusb 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046a:00a4 Cherry GmbH 
Bus 001 Device 003: ID 1bcf:0005 Sunplus Innovation Technology Inc. Optical Mouse
Bus 001 Device 002: ID 1bcf:0007 Sunplus Innovation Technology Inc. Optical Mouse
Bus 001 Device 005: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy series, misc. (MTP mode)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

With the YubiKey:

$ lsusb 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046a:00a4 Cherry GmbH 
Bus 001 Device 003: ID 1bcf:0005 Sunplus Innovation Technology Inc. Optical Mouse
Bus 001 Device 006: ID 1050:0407 Yubico.com Yubikey 4 OTP+U2F+CCID
Bus 001 Device 005: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy series, misc. (MTP mode)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Note that the YubiKey is connected to Bus 001. This USB bus was already existing. And will still exist after I remove the key.

Maybe you can configure your BIOS/UEFI to change the configuration of your USB-C port on the mother board?

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

Any progress on this issue?
Do you know why the USB bus is created ONLY when the device is connected?

from pcsc.

savely-krasovsky avatar savely-krasovsky commented on July 23, 2024

I had similar issue after updating to Fedora 30. With Fedora 29 everything works well. I use Yubikey 4 and Yubikey 5 NFC.

Unplugging:

01000595 ccid_usb.c:857:WriteUSB() write failed (1/10): -4 LIBUSB_ERROR_NO_DEVICE

Plugging:

00822239 ifdhandler.c:150:CreateChannelByNameOrChannel() failed
00000011 readerfactory.c:1105:RFInitializeReader() Open Port 0x200000 Failed (usb:1050/0407:libudev:0:/dev/bus/usb/001/011)
00000002 readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.
00026929 ifdhandler.c:150:CreateChannelByNameOrChannel() failed
00000008 readerfactory.c:1105:RFInitializeReader() Open Port 0x200001 Failed (usb:1050/0407:libudev:1:/dev/bus/usb/001/011)
00000002 readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.

lsusb log:

$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 001 Device 003: ID 05ac:0256 Apple, Inc. USB DEVICE
Bus 001 Device 011: ID 1050:0407 Yubico.com Yubikey 4 OTP+U2F+CCID
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 001 Device 003: ID 05ac:0256 Apple, Inc. USB DEVICE
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 001 Device 003: ID 05ac:0256 Apple, Inc. USB DEVICE
Bus 001 Device 012: ID 1050:0407 Yubico.com Yubikey 4 OTP+U2F+CCID
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

from pcsc.

jrobsonchase avatar jrobsonchase commented on July 23, 2024

Hi, sorry for the long silence. I changed jobs shortly after submitting this issue and got a new computer that didn't exhibit the problematic behavior. That said,

Maybe you can configure your BIOS/UEFI to change the configuration of your USB-C port on the mother board?

I did play briefly with the "Thunderbolt BIOS Assist" setting on my old laptop, and setting it one way (can't remember which 😕) made the problem go away. I've been hesitant to mess with it on my new computer after seeing reports of bricking after changing it. I'm not entirely clear on what the setting actually does or what its trade-offs are.

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

@L11R I think your problem is different.
Follow https://ccid.apdu.fr/#support

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

The problem was a BIOS/UEFI feature/bug issue.
Closing.

from pcsc.

daveman1010221 avatar daveman1010221 commented on July 23, 2024

I have this same issue on Ubuntu 20.04. Is there some way I can make pcscd ignore the yubikey? I don't intend to use it as a smart card but I need pcscd for a different reader and would love if I could get pcscd to stop filling up my syslog.

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

@daveman1010221 have you tried to upgrade your computer BIOS?

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

You can also ignore a reader. See https://ludovicrousseau.blogspot.com/2015/12/remove-andor-customize-pcsc-reader-names.html

from pcsc.

daveman1010221 avatar daveman1010221 commented on July 23, 2024

I attempted to ignore the reader, using the method "left as an exercise to the reader" for systemd. This was my result:

May 20 10:10:16 pcscd[103813]: /usr/sbin/pcscd: unrecognized option '--enable-filter'
May 20 10:10:16 pcscd[103813]: Usage: /usr/sbin/pcscd options
May 20 10:10:16 pcscd[103813]: Options:
May 20 10:10:16 pcscd[103813]:   -a, --apdu                log APDU commands and results
May 20 10:10:16 pcscd[103813]:   -c, --config                path to reader.conf
May 20 10:10:16 pcscd[103813]:   -f, --foreground        run in foreground (no daemon),
May 20 10:10:16 pcscd[103813]:                         send logs to stdout instead of syslog
May 20 10:10:16 pcscd[103813]:   -T, --color                force use of colored logs
May 20 10:10:16 pcscd[103813]:   -h, --help                display usage information
May 20 10:10:16 pcscd[103813]:   -H, --hotplug                ask the daemon to rescan the available readers
May 20 10:10:16 pcscd[103813]:   -v, --version                display the program version number
May 20 10:10:16 pcscd[103813]:   -d, --debug                display lower level debug messages
May 20 10:10:16 pcscd[103813]:   -i, --info                display info level debug messages
May 20 10:10:16 pcscd[103813]:   -e  --error                display error level debug messages (default level)
May 20 10:10:16 pcscd[103813]:   -C  --critical        display critical only level debug messages
May 20 10:10:16 pcscd[103813]:   --force-reader-polling ignore the IFD_GENERATE_HOTPLUG reader capability
May 20 10:10:16 pcscd[103813]:   -t, --max-thread        maximum number of threads (default 200)
May 20 10:10:16 pcscd[103813]:   -s, --max-card-handle-per-thread        maximum number of card handle per thread (default: 200)
May 20 10:10:16 pcscd[103813]:   -r, --max-card-handle-per-reader        maximum number of card handle per reader (default: 200)
May 20 10:10:16 pcscd[103813]:   -x, --auto-exit        pcscd will quit after 60 seconds of inactivity
May 20 10:10:16 pcscd[103813]:   -S, --reader-name-no-serial    do not include the USB serial number in the name
May 20 10:10:16 pcscd[103813]:   -I, --reader-name-no-interface do not include the USB interface name in the name
May 20 10:10:16 systemd[1]: pcscd.service: Main process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- An ExecStart= process belonging to unit pcscd.service has exited.
-- 
-- The process' exit code is 'exited' and its exit status is 1.
May 20 10:10:16 systemd[1]: pcscd.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- The unit pcscd.service has entered the 'failed' state with result 'exit-code'.

Other info:
/usr/sbin/pcscd --version
pcsc-lite version 1.8.26.
Copyright (C) 1999-2002 by David Corcoran [email protected].
Copyright (C) 2001-2018 by Ludovic Rousseau [email protected].
Copyright (C) 2003-2004 by Damien Sauveron [email protected].
Report bugs to [email protected].
Enabled features: Linux x86_64-pc-linux-gnu libsystemd serial usb libudev usbdropdir=/usr/lib/pcsc/drivers ipcdir=/run/pcscd filter configdir=/etc/reader.conf.d

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

You need to rebuild pcsc-lite.
To enable these two features you need to configure pcsc-lite with --enable-filter.

from pcsc.

daveman1010221 avatar daveman1010221 commented on July 23, 2024

libpcsclite-dev is what I have installed on Ubuntu. Is this what you mean to rebuild?

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

No. Get the source code and rebuild the software.
If you are not a developer it will be complex.
I am not sure at all it would solve your problem.

from pcsc.

daveman1010221 avatar daveman1010221 commented on July 23, 2024

Ok, I can build it from source. Just wanted to confirm you meant only the library, not the daemon?

from pcsc.

LudovicRousseau avatar LudovicRousseau commented on July 23, 2024

@jrobsonchase @L11R @daveman1010221 I fixed this bug in a3e09df
It is not yet included in a stable version of pcsc-lite.

You can also reader issue #125

from pcsc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.