From nobody Mon Feb 9 09:16:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611156949; cv=none; d=zohomail.com; s=zohoarc; b=KfMjAfWcPwZvgebkpwyJ6bmrzBTHf9e4enTcoK9enGwhm0SCou+Trt6VFP7CDL/UvuMViMI1VHQ5VIWZ2yJ8pTmuUxb4c6Grn37qMAqzO9+SHF+BAcs9XfJXFbzEY7ThrTypdPR16kChs7ml3XghJm+1jFZuuvxWYmDHgf3vgNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611156949; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=vy08SPUQILRszwUrUSWnviExWQtbBP9Rn4kirCQh3nA=; b=ZzAEtQVAff12BA3KA8e3irk5KlliEtjW2EU2rz3z8dGYz1iYquM93DzY6X+GGDkZCcV+IBkBRpoefP+DPee898D7H93zx4SOia2SDbZD+Ysy4bphlG50Lzc0DehINNTdYhkwh6heCq0ECxs/sxzS4SpB1s0O9ValmMWE4szFvYg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1611156949199355.14076675497563; Wed, 20 Jan 2021 07:35:49 -0800 (PST) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-U5R6W5voPiS4s9fJTjar2w-1; Wed, 20 Jan 2021 10:35:43 -0500 Received: by mail-ed1-f71.google.com with SMTP id l33so11217138ede.1 for ; Wed, 20 Jan 2021 07:35:42 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (13.red-83-57-169.dynamicip.rima-tde.net. [83.57.169.13]) by smtp.gmail.com with ESMTPSA id fi12sm1047413ejb.49.2021.01.20.07.35.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 07:35:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611156948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vy08SPUQILRszwUrUSWnviExWQtbBP9Rn4kirCQh3nA=; b=WPY63YnpOQvaCeK/VbZmdcvq3BTV2rE36JtayB37OYJktmmWIvbOoWDf4CCyOjTqZS8/Eh d485kJmLr+0oH1sCEvZ9UBe2vopK1IJlOeIRtK5njffx/T8tzEECumi7rV7b6IemMF5uO1 +SSQHNKcgISSlIZRHZ1Optq1FpBW+d4= X-MC-Unique: U5R6W5voPiS4s9fJTjar2w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vy08SPUQILRszwUrUSWnviExWQtbBP9Rn4kirCQh3nA=; b=bRsv++wIgyLfHbvFMaLgnZVAoiZFAIGpbhD3lv4j1ZRHKiZRaS9AmCoat7OUliwO5P ku+JoBJHofGU36E68x63sbtzMmqUM2jXEpECSg0kWp2g/dEyNjHL2hfFdf1Y9jNeY3cZ ftJM3a/aUjCICj90DWACFt/wiCMTXdwz5T7YsETvJTHFVwY9RAHMXfsH6SHbXpQZoym0 xhkJdkhy97DZ3dwnO8or7ugGF3jXnRNVOivX8iaukM4G6zTzSEoyCnl5j+kk/2kmauOH fp5/BP+7SB6cww/LAv+mzCMXFgqzeNU+dH7W8X/nZiavseksN+kccgS5n1jLxg5eozik 1BLQ== X-Gm-Message-State: AOAM530VR2Lio+EPEuQi+uJwQ96LDD+7r+jW/bsCwc48uuDfdqTOb8PE uVhF0zpHubAzPAjyySXFK/QeBGiK4En/KTSs70wW8wsgtfvwdxgIydM55spkwOMsVQvqXzy6fWS GBZ/F2kRk0JjJVw== X-Received: by 2002:a05:6402:1714:: with SMTP id y20mr7449728edu.360.1611156941668; Wed, 20 Jan 2021 07:35:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8enPAcy7hcRg7vWLAhqswghY4GH4q3U2qKOzBkcNB+KYFU91/zupqwyEmoJs/pn+sTan90Q== X-Received: by 2002:a05:6402:1714:: with SMTP id y20mr7449702edu.360.1611156941492; Wed, 20 Jan 2021 07:35:41 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Fam Zheng , Gerd Hoffmann , qemu-block@nongnu.org, Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ed Maste , Daniele Buono , Han Han , Eric Blake , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Gustavo A . R . Silva" Subject: [PATCH v2 3/3] hw/usb/dev-uas: Report command additional adb length as unsupported Date: Wed, 20 Jan 2021 16:35:22 +0100 Message-Id: <20210120153522.1173897-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210120153522.1173897-1-philmd@redhat.com> References: <20210120153522.1173897-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We are not ready to handle additional CDB data. If a guest sends a packet with such additional data, report the command parameter as not supported. Specify a size (of 1 byte) for the add_cdb member we are not using, to fix the following warning: usb/dev-uas.c:157:31: error: field 'status' with variable sized type 'uas= _iu' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-= variable-sized-type-not-at-end] uas_iu status; ^ Reported-by: Ed Maste Reported-by: Daniele Buono Reported-by: Han Han Reviewed-by: Eric Blake Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- Cc: Marc-Andr=C3=A9 Lureau Cc: Paolo Bonzini Cc: Gustavo A. R. Silva v2: include Eric feedbacks --- hw/usb/dev-uas.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index cec071d96c4..a51402bc0bf 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -16,6 +16,7 @@ #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/module.h" +#include "qemu/log.h" =20 #include "hw/usb.h" #include "migration/vmstate.h" @@ -70,7 +71,7 @@ typedef struct { uint8_t reserved_2; uint64_t lun; uint8_t cdb[16]; - uint8_t add_cdb[]; + uint8_t add_cdb[1]; /* not supported by QEMU */ } QEMU_PACKED uas_iu_command; =20 typedef struct { @@ -700,6 +701,11 @@ static void usb_uas_command(UASDevice *uas, uas_iu *iu) uint32_t len; uint16_t tag =3D be16_to_cpu(iu->hdr.tag); =20 + if (iu->command.add_cdb_length > 0) { + qemu_log_mask(LOG_UNIMP, "additional adb length not yet supported\= n"); + goto unsupported_len; + } + if (uas_using_streams(uas) && tag > UAS_MAX_STREAMS) { goto invalid_tag; } @@ -735,6 +741,10 @@ static void usb_uas_command(UASDevice *uas, uas_iu *iu) } return; =20 +unsupported_len: + usb_uas_queue_fake_sense(uas, tag, sense_code_INVALID_PARAM_VALUE); + return; + invalid_tag: usb_uas_queue_fake_sense(uas, tag, sense_code_INVALID_TAG); return; --=20 2.26.2