From nobody Wed Apr 16 00:13:35 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1733994913; cv=none; d=zohomail.com; s=zohoarc; b=DcgD+gNydlaj4ADaMDFg48Ro1LEyWJ/7LCYNjtZ9WrbEf8fv6mPYvkn2JHrOTUZ/FRGe7mZXFRgQC96Lz9wida19LQA5uIzSO2i7VeBXbP2mlQ37m3UeUXd2HyGamcWk0OD6Ss0In7Gn/9jFknDKdGJRiDubfzjhs/kiY5qg4FQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733994913; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yTdRLETnDJrohYBMUvZokfWyJ2vN454iXatV/Zh1U68=; b=gks+fQAcAVs4hSJ1X+p93iRvVhO00HzFvuy8zRvis8Z08FKUdS3S4Uz3uFh5kJflASwPTQ8E4rUm2KmYJoH4lkWiGKemX5REITyfNs6aHftczXrfD4F1ntyygHGMKyyR0yxtAgXItQQKhLoxclcT6fVsZMVRZyAoOSGeaVd5ytQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1733994913385386.2378570389759; Thu, 12 Dec 2024 01:15:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLfGk-0004Bw-8s; Thu, 12 Dec 2024 04:14:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLfGi-00049l-FP for qemu-devel@nongnu.org; Thu, 12 Dec 2024 04:14:00 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tLfGd-0008RJ-Nv for qemu-devel@nongnu.org; Thu, 12 Dec 2024 04:14:00 -0500 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-7f46d5d1ad5so296547a12.3 for ; Thu, 12 Dec 2024 01:13:55 -0800 (PST) Received: from wheely.local0.net ([1.146.48.169]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f142d92e2csm787021a91.9.2024.12.12.01.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 01:13:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733994834; x=1734599634; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yTdRLETnDJrohYBMUvZokfWyJ2vN454iXatV/Zh1U68=; b=YbF0RUeTlIjf4ASFKzHTuQgiXhv29/SJdxDRMDbMAORph6WHZ08sZA/JJPBzHaHd3r 1scnP/fAA5J/23f/n3ua4juEGno3ZEUmZkkSSmLlfMGSyd45BpMp0Pbyty1pq5XNZTrL rKmo0aHhiMMD6xUWpBLQOuJ2EPvuKK9VIaLfmbRQY85dgbB0/Z8RLTa61IxdsZuTsPkK uZnR7LXLLJq5WlDpWGaoVYUmsgI7x8zH+K6FVbSs0b65klN3h5fU5qX+yy3XPQo6Yqpi k0QkZ963x0vG042IAsO+I7xil1bPlSF0g5VY6iFWMFXr32BoPS8uM7DOY6c3F9tjsvAW 4osQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733994834; x=1734599634; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yTdRLETnDJrohYBMUvZokfWyJ2vN454iXatV/Zh1U68=; b=wLK/00Np5XQczATfiiTy999t2hc8qyOqmxP2rul3t2rD47z330I77PJdjDOmyzOMU2 FD4+qSAkRAubtEEWnfP2CzRTieAaBvxAPUbfLBEa7B0yZqBQEa20RWqAf4+j0or3iX91 efT/e1JZ9UXX6Bh36y/u13paI/Lpa2+U9Ia3VrCAcTo5BJ+f/jvNz4jKwoDVgMg5W8wx v7BL5+u1TEwelj0VKVoIhY4C28QsdVM88C9r71hTa+x76u9Yv1voa4XOITP1Tby2h2J+ XIMWmJBqmAuIjuWhHcoXy+DujA0qVm41Xzrd5BtDQvuk9ZMFgfWkvTJ4EPt0ZQM4gL9p 9tVQ== X-Gm-Message-State: AOJu0YyX26a6O41zDijJIYGor8sKwErnlJylEBin4GONgoGGvZcpqWp1 ruyZApULgY9y7CJat9867eDaE0MbPijar1MTrulCoSXzHHOW0eXZ7snuYQ== X-Gm-Gg: ASbGncveg+rAuDltcL1VHvtgBZWcjLE6sbC+j2BuMgg0h8lVBCgm1NWhZIM23Ouc0e/ 4L/zUvDn0s7b9Y3kEOIUEobEQbmwdrzCPfWlYqO2MMX8bU9sQth0/VnlqGJhyGwXaakwgtBxnER 8R9CYsJAcT3MfuNG3tYrM5UAZB7bdUnjAKksNAALktYxjaiUoaxRggGXtikCufPNg/wDBrZBcDu fgOs7qaSAL1uBKI+NoxEN4R0h+YnJYsSPJUaSJdLTpghyB0Uh3Rc2a4pIY= X-Google-Smtp-Source: AGHT+IFVOJuRD7FHgGvirzgcMQ4JSI7ykWjx2o5xjq5fMLTgQ+BFboEdlT6hhn+FL1a5IWDvzZb/tA== X-Received: by 2002:a17:90b:2ec8:b0:2ea:b564:4b31 with SMTP id 98e67ed59e1d1-2f127fea997mr8744289a91.19.1733994833926; Thu, 12 Dec 2024 01:13:53 -0800 (PST) From: Nicholas Piggin To: qemu-devel@nongnu.org Cc: Nicholas Piggin , Gerd Hoffmann , Kevin Wolf Subject: [PATCH 06/11] usb/msd: Allow CBW packet size greater than 31 Date: Thu, 12 Dec 2024 19:13:17 +1000 Message-ID: <20241212091323.1442995-7-npiggin@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241212091323.1442995-1-npiggin@gmail.com> References: <20241212091323.1442995-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=npiggin@gmail.com; helo=mail-pg1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1733994914003116600 Content-Type: text/plain; charset="utf-8" The CBW structure is 31 bytes, so CBW DATAOUT packets must be at least 31 bytes. QEMU enforces exactly 31 bytes, but this is inconsistent with how it handles CSW packets (where it allows greater than or equal to 13 bytes) despite wording in the spec[*] being similar for both packet types: "shall end as a short packet with exactly 31 bytes transferred". [*] USB MSD Bulk-Only Transport 1.0 For consistency, and on the principle of being tolerant in accepting input, relax the CBW size check. Alternatively, both checks could be tightened to exact. Or a message could be printed warning of possible guest error if size is not exact, but still accept the packets. Signed-off-by: Nicholas Piggin --- hw/usb/dev-storage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index af9eb7ea8a5..064bb700cbc 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -400,7 +400,7 @@ static bool try_get_valid_cbw(USBPacket *p, struct usb_= msd_cbw *cbw) { uint32_t sig; =20 - if (p->iov.size !=3D 31) { + if (p->iov.size < 31) { qemu_log_mask(LOG_GUEST_ERROR, "usb-msd: Bad CBW size %ld\n", p->iov.size); return false; --=20 2.45.2