All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Fritsch <sf@sfritsch.de>
To: Gerd Hoffmann <kraxel@redhat.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 6/8] usb-ccid: Fix chaining fields in CCID USB messages
Date: Thu, 20 Jul 2017 11:02:49 +0200	[thread overview]
Message-ID: <1500541371-24788-7-git-send-email-sf@sfritsch.de> (raw)
In-Reply-To: <1500541371-24788-1-git-send-email-sf@sfritsch.de>

From: Stefan Fritsch <stefan_fritsch@genua.de>

Incoming packets should never need chaining (bChainParamter => 0).
If they ever do we will have to fix this later. Zero is still better
than an uninitialized value.

Warn if outgoing packets try to use chaining (wLevelParameter != 0).
As we are doing APDU level exchanges, the driver should not need to
set these bits.

Signed-off-by: Stefan Fritsch <stefan_fritsch@genua.de>
Signed-off-by: Christian Ehrhardt <christian_ehrhardt@genua.de>
---
 hw/usb/dev-smartcard-reader.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index bc4dc35d3f..709c65c384 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -826,6 +826,7 @@ static void ccid_write_data_block(USBCCIDState *s, uint8_t slot, uint8_t seq,
     p->b.hdr.bSeq = seq;
     p->b.bStatus = ccid_calc_status(s);
     p->b.bError = s->bError;
+    p->bChainParameter = 0;
     if (p->b.bError) {
         DPRINTF(s, D_VERBOSE, "error %d\n", p->b.bError);
     }
@@ -1027,6 +1028,10 @@ static void ccid_on_apdu_from_guest(USBCCIDState *s, CCID_XferBlock *recv)
     len = le32_to_cpu(recv->hdr.dwLength);
     DPRINTF(s, 1, "%s: seq %d, len %d\n", __func__,
                 recv->hdr.bSeq, len);
+    if (le16_to_cpu(recv->wLevelParameter)) {
+        DPRINTF(s, D_WARN, "Unsupported non-zero level Parameter %x\n",
+                le16_to_cpu(recv->wLevelParameter));
+    }
     ccid_add_pending_answer(s, (CCID_Header *)recv);
     if (s->card && len <= BULK_OUT_DATA_SIZE) {
         ccid_card_apdu_from_guest(s->card, recv->abData, len);
-- 
2.11.0

  parent reply	other threads:[~2017-07-20  9:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-20  9:02 [Qemu-devel] [PATCH v2 0/8] usb-ccid: Misc fixes and T=1 support Stefan Fritsch
2017-07-20  9:02 ` [Qemu-devel] [PATCH v2 1/8] usb-ccid: Add support to dump all USB packets Stefan Fritsch
2017-07-21  6:09   ` Gerd Hoffmann
2017-07-27  8:55     ` Stefan Fritsch
2017-07-20  9:02 ` [Qemu-devel] [PATCH v2 2/8] usb-ccid: Fix USB packet generation for 64-Bytes sized packets Stefan Fritsch
2017-07-20  9:02 ` [Qemu-devel] [PATCH v2 3/8] usb-ccid: Set protocol parameters based on card ATR Stefan Fritsch
2017-07-20  9:35   ` Marc-André Lureau
2017-07-20  9:02 ` [Qemu-devel] [PATCH v2 4/8] usb-ccid: Fix ATR parsing Stefan Fritsch
2017-07-20  9:40   ` Marc-André Lureau
2017-07-20  9:02 ` [Qemu-devel] [PATCH v2 5/8] usb-ccid: Fix USB descriptor Stefan Fritsch
2017-07-20  9:44   ` Marc-André Lureau
2017-07-20 12:16     ` Stefan Fritsch
2017-07-20  9:02 ` Stefan Fritsch [this message]
2017-07-20  9:02 ` [Qemu-devel] [PATCH v2 7/8] usb-ccid: Increase ccid max APDU size Stefan Fritsch
2017-07-20  9:02 ` [Qemu-devel] [PATCH v2 8/8] usb-ccid: Reduce logging at level WARN Stefan Fritsch
2017-07-20  9:49   ` Marc-André Lureau
2017-07-20 12:18     ` Stefan Fritsch
2017-07-27  8:58       ` Stefan Fritsch

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=1500541371-24788-7-git-send-email-sf@sfritsch.de \
    --to=sf@sfritsch.de \
    --cc=kraxel@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.