Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4489616rwb; Tue, 6 Sep 2022 08:12:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Xzk7hyQoaxjbji6mbeRcqrOYBs9Fgbrvqe0GFHXSIY5tKbVSGCLN4nwqM0JQ80x0aChJg X-Received: by 2002:a17:907:a0c7:b0:76f:35bb:5795 with SMTP id hw7-20020a170907a0c700b0076f35bb5795mr1887134ejc.308.1662477170083; Tue, 06 Sep 2022 08:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662477170; cv=none; d=google.com; s=arc-20160816; b=DQh7mKcetaUQxMZ/l57qYZq6sdBT6Uz490bZVvApVQPtBYHXXJHbmDcZbWnIiIbxPp 3o2qhj062mZn6UPm540+FvfJUWfp/X2ebH5SGaP4BFyU+Qq8W0v5guVYVt87SrYfzsE/ 98dxLguGi5AAi24V9EzxadTJJ8nPaxa7gJvEwFyhVATXkr+BbxLm13dxV6rWSrV7v7Fn ctGFarSvCBa7RGoj/77G8K8YmN7PB4i+sS9gxjudaOMef/AGja3HcQlARwd4qnnF8chC O+EJ7EWrO8ArebIb/xHjy7AYkyjYHlMqCpssXekma3VC8oVSMXboH8NZo+EQyd03IOUb Pddw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jMLcc6nkWkc0d1Qbg666z/pbASiq/mpc1C/n5wZ1ySA=; b=am56jwPcUpQ7GSCA/t1ffIRwZ2yGrXQNcbhgAVcmUgKHb7fYTDsSjsFXlC0dpp2DQl vCIlyz2SQXI9xT7R09cAyPD0hJhtezhwAirK6AtvxsJhv6C8TsfaBqFRXMxeRv3ZtcDp n3Um6igGaegEg4TBPbsVxuOVEcLLu1kujQ5iF7MSTeW2PVO73wpcDlkETD/0112DOtm1 HwVxl2sflGA/dPXO4NccN5Dj5MwlPmP7QHcwQrPsw0EbA3PQs5U6XxAyu4x7pZVf/X9N /PTzn738xJ38JZo2XJcaokWIXC1vLstjtZHML4CEJ2aAF6CSEIfkNCgaOxx41mnuOd4y I2RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pBEcxPSV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mf23-20020a170906cb9700b0073d9b010074si8363298ejb.824.2022.09.06.08.12.25; Tue, 06 Sep 2022 08:12:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pBEcxPSV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234287AbiIFNk2 (ORCPT + 99 others); Tue, 6 Sep 2022 09:40:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240870AbiIFNiz (ORCPT ); Tue, 6 Sep 2022 09:38:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4E466556D; Tue, 6 Sep 2022 06:36:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AEDD9B81637; Tue, 6 Sep 2022 13:35:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9DBFC433D7; Tue, 6 Sep 2022 13:34:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471299; bh=g4OSy4eiWzd4GXoIulDPPUyvFbwo6gtuf8PChh14Lrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pBEcxPSVaOg9yNrkcRiI7mcz4PS1Z6XTXUvjxABrsRcQyeudlNR0WUcU5YtcvvCNR HitfmDCwl+WEuXvhgLz3Mp0i1loa1TJ5YIV3FNZcqyu1ec+m11WMzoSBKY8jXezDmJ f05oSYwU0c5wBhbR0v1F9B/Wh22/OZ2pqifveb00= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Krishna Kurapati Subject: [PATCH 5.10 63/80] usb: gadget: mass_storage: Fix cdrom data transfers on MAC-OS Date: Tue, 6 Sep 2022 15:31:00 +0200 Message-Id: <20220906132819.699277453@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132816.936069583@linuxfoundation.org> References: <20220906132816.936069583@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Krishna Kurapati commit 9d4dc16ec71bd6368548e9743223e449b4377fc7 upstream. During cdrom emulation, the response to read_toc command must contain the cdrom address as the number of sectors (2048 byte sized blocks) represented either as an absolute value (when MSF bit is '0') or in terms of PMin/PSec/PFrame (when MSF bit is set to '1'). Incase of cdrom, the fsg_lun_open call sets the sector size to 2048 bytes. When MAC OS sends a read_toc request with MSF set to '1', the store_cdrom_address assumes that the address being provided is the LUN size represented in 512 byte sized blocks instead of 2048. It tries to modify the address further to convert it to 2048 byte sized blocks and store it in MSF format. This results in data transfer failures as the cdrom address being provided in the read_toc response is incorrect. Fixes: 3f565a363cee ("usb: gadget: storage: adapt logic block size to bound block devices") Cc: stable@vger.kernel.org Acked-by: Alan Stern Signed-off-by: Krishna Kurapati Link: https://lore.kernel.org/r/1661570110-19127-1-git-send-email-quic_kriskura@quicinc.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/storage_common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/usb/gadget/function/storage_common.c +++ b/drivers/usb/gadget/function/storage_common.c @@ -294,8 +294,10 @@ EXPORT_SYMBOL_GPL(fsg_lun_fsync_sub); void store_cdrom_address(u8 *dest, int msf, u32 addr) { if (msf) { - /* Convert to Minutes-Seconds-Frames */ - addr >>= 2; /* Convert to 2048-byte frames */ + /* + * Convert to Minutes-Seconds-Frames. + * Sector size is already set to 2048 bytes. + */ addr += 2*75; /* Lead-in occupies 2 seconds */ dest[3] = addr % 75; /* Frames */ addr /= 75;