From nobody Wed Apr 16 04:23:38 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=1744361174; cv=none; d=zohomail.com; s=zohoarc; b=eerafR4EB79WukClHjQMNpW6MBrr8fmrxVe0dXZ4Z8rxma7l5+uBCmBhW/XFaHwv9Fz0x+3pAval7cOxdkHpGJRjF0ngKpMiHO7rSRX01yXjmiitgHp/eYbCncqy1+1PBWFATk8i9DXqW7qWhiVl8/zNdYIlHPnclw2rG5lkoUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744361174; 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=SWO2MpNR+Wq7+HXx3Lk8VZg+9OETBCuvoauKUfERGVY=; b=WIsvz2bT5pXyYTwavKM89VDIZm6QnHCjjijhyEv5rmPMDmsvzfe0D1+377CN4oAXlCy+yqBbAnStuJuvb61b4LVsnGqPjVjP+4PkoZe6+Ld+NhZZcrI9kr/VQJjxoXrlT15uAagIr3QbsrHkFhZ2bC+S0oGqIsSO3miqUAhe/M8= 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 17443611748151012.2660378071156; Fri, 11 Apr 2025 01:46:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u39Ng-0001s8-H4; Fri, 11 Apr 2025 04:04:56 -0400 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 1u39Ne-0001rP-LM for qemu-devel@nongnu.org; Fri, 11 Apr 2025 04:04:54 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u39Nd-0004i5-1S for qemu-devel@nongnu.org; Fri, 11 Apr 2025 04:04:54 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-227c7e57da2so15885055ad.0 for ; Fri, 11 Apr 2025 01:04:52 -0700 (PDT) Received: from wheely.local0.net ([220.253.99.94]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22ac7c95c83sm43048065ad.147.2025.04.11.01.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Apr 2025 01:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744358692; x=1744963492; 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=SWO2MpNR+Wq7+HXx3Lk8VZg+9OETBCuvoauKUfERGVY=; b=Ueh10OKSG5Zp4i0EnaF8IRB1WffvIZNkzxZ2iVRd8YQ/JlRG27XP9OfNCdHKAEKyY7 y21iVIRwo04vpLOGVDQXyS1FXHtW500Iayvc3wnkVv96sVd6QZRA9XyLq9N7yyGcPdom trXdrKSsyEWUi785ioy78a01pHc/efNwBIVEc6ZrXs//gidpYnPLtqoE/gPQDoUfmBOy P8HMpt6Vy1NV2AKVzg8CH0Yw9f+Q/28+9oGprfj4GZysY4k2Cc4jUCmK00PKuUXTRS1z VbL4O8igHd/bM2xTg8hIz9kMFA4yxrRaWaTsL2LKwk7CoLy0G//CUd+ky0f84pMWxsjt hFdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744358692; x=1744963492; 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=SWO2MpNR+Wq7+HXx3Lk8VZg+9OETBCuvoauKUfERGVY=; b=GOwiYM/Xz8KPgOzP+gYHaiJi5uFuNloAoi25XVjvfUjESaRweXsAF8v9guxJJhPskH Gs95uneVyih6T/3F3xiRMCPg157nWoLRITwXcDaV/JPQYJ3ZHuZ5EgYhG4TcqQaSnBHh hICD+oUyBmLWbllj09Agb79PVlh4Y4HsnVJ+2aK1sj+lCIIMSz4EoR+jkkO/A4i6nMi4 +l+4TBSXxbjvt2PRLS9AQ+bh4ZH4SfNI75FgWyRgV8TXPRmeJsAJdJreH8uDhZreMRby hqLQC5FjltEPcIG+Wo5W6WdedL9IkQWVm1FjPpSyE9TyqGNKatFQ/RBh580dGPQUcogi 87mw== X-Forwarded-Encrypted: i=1; AJvYcCXjtTHjSCgK4eOlEjC1ZTjEz3g4UN+Ff6kiHg+bRnprwR7cMUnmP8Wx4rmvPHcZmqQFCR0BdPsQCdLn@nongnu.org X-Gm-Message-State: AOJu0YweGL17LIwTIqGqpEAmK8fTXHm/WlzgNkQKe6p+wY63t/Oy+KfD gTpeGGv8PabLmUaqQuhJuXklOoTdv0RXqIWgHR3Az4ufd1sG6utP X-Gm-Gg: ASbGnct9Zi59VeYmUptn2bsyLZtAuCDTnZX/QJeS+0YWcPaOOP71DVWxmDdmAYSnef+ jrOAa2AH41hyzyVwvYqImkaMOyZiJFb/jLxTQLDggnGK5Afj8HBKSEQp1zxXNWaR+m28cXxHqXQ u+Jma3JD6kk1rLHYjsd0gQ6xqCI3jFaNRYbo68xHh9CudCXrEDL5KhWIiXZxUtWfKXXuRjYLQqV Wxqj3Nw8H7LoTcxMqn45H0Lu9QDgc9QQV2tk1LaxmufjloCVFxbAO/1txoqkXdX/mDeJKQkD0Of ESW8XuXpwKXNzZJ5Qfzee/bjkk0X9blNAsbzeQCui4gt X-Google-Smtp-Source: AGHT+IEWLLB5jaPOfmOZqay5OMus7igJMgH2AceMaH8QP15MjI+Ue7E/Orl7N7qOICElf4nTZYoULg== X-Received: by 2002:a17:903:3c6d:b0:224:a74:28c2 with SMTP id d9443c01a7336-22bea4c3e94mr32558085ad.29.1744358691712; Fri, 11 Apr 2025 01:04:51 -0700 (PDT) From: Nicholas Piggin To: Gerd Hoffmann Cc: Nicholas Piggin , qemu-devel@nongnu.org, Kevin Wolf Subject: [PATCH v2 05/10] usb/msd: Allow CBW packet size greater than 31 Date: Fri, 11 Apr 2025 18:04:26 +1000 Message-ID: <20250411080431.207579-6-npiggin@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250411080431.207579-1-npiggin@gmail.com> References: <20250411080431.207579-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::636; envelope-from=npiggin@gmail.com; helo=mail-pl1-x636.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: 1744361175266019000 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 6668114ea74..27093de5c84 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 %zu\n", p->iov.size); return false; --=20 2.47.1