From: David Bouman <dbouman03@gmail.com>
To: qemu-devel@nongnu.org
Cc: David Bouman <dbouman03@gmail.com>
Subject: [PATCH 4/4] hw/usb/u2f-passthru: Implement FIDO U2FHID keep-alive
Date: Tue, 25 Jun 2024 16:53:50 +0200 [thread overview]
Message-ID: <20240625145350.65978-5-dbouman03@gmail.com> (raw)
In-Reply-To: <20240625145350.65978-1-dbouman03@gmail.com>
FIDO U2FHID features a keep-alive response command (code 0xbb). A
keep-alive response signifies that the request is being processed
and the transaction should not be closed yet.
u2f-passthru does not recognize this command, and hence closes the
transaction prematurely upon receiving it. This prevents some U2F
security keys from being passed through correctly (Yubikey 4/5).
Fix this by recognizing the keep-alive response and, if received,
by keeping the transaction alive regardless of the resp_bcnt limit.
Signed-off-by: David Bouman <dbouman03@gmail.com>
Fixes: 299976b050bf (hw/usb: Add U2F key passthru mode)
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2293
---
hw/usb/u2f-passthru.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/hw/usb/u2f-passthru.c b/hw/usb/u2f-passthru.c
index d0fb7b377c..c1e4db3467 100644
--- a/hw/usb/u2f-passthru.c
+++ b/hw/usb/u2f-passthru.c
@@ -296,10 +296,14 @@ static void u2f_passthru_recv_from_host(U2FPassthruState *key,
return;
}
+ bool keepalive = false;
if (packet_is_init(packet)) {
transaction->resp_bcnt = packet_init_get_bcnt(packet);
transaction->resp_size = PACKET_INIT_DATA_SIZE;
+ if (packet->init.cmd == U2FHID_CMD_KEEPALIVE)
+ keepalive = true;
+
if (packet->cid == BROADCAST_CID) {
/* Nonce checking for legitimate response */
if (memcmp(transaction->nonce, packet->init.data, NONCE_SIZE)
@@ -312,7 +316,7 @@ static void u2f_passthru_recv_from_host(U2FPassthruState *key,
}
/* Transaction end check */
- if (transaction->resp_size >= transaction->resp_bcnt) {
+ if (!keepalive && transaction->resp_size >= transaction->resp_bcnt) {
u2f_transaction_close(key, cid);
}
u2f_send_to_guest(&key->base, raw_packet);
--
2.34.1
prev parent reply other threads:[~2024-06-25 17:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 14:53 [PATCH 0/4] hw/usb/u2f-passthru: U2F keepalive fixes David Bouman
2024-06-25 14:53 ` [PATCH 1/4] hw/usb/u2f: Add `start` and `stop` callbacks to U2F key class David Bouman
2024-06-25 14:53 ` [PATCH 2/4] hw/usb/u2f-passthru: Do not needlessly retain handle to hidraw chardev David Bouman
2024-06-25 14:53 ` [PATCH 3/4] hw/usb/u2f-passthru: Clean up code David Bouman
2024-06-25 14:53 ` David Bouman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240625145350.65978-5-dbouman03@gmail.com \
--to=dbouman03@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).