Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4445381rwb; Tue, 6 Sep 2022 07:38:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR5MaXMWbMWIsb8M3bEtXA5sk01j06rQ84j6cv7mN/sWnxQynERkTCS4GGBuFjunKoXpOJOg X-Received: by 2002:a05:6a00:2918:b0:536:3967:5d08 with SMTP id cg24-20020a056a00291800b0053639675d08mr55236247pfb.68.1662475133839; Tue, 06 Sep 2022 07:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662475133; cv=none; d=google.com; s=arc-20160816; b=IVxncDImTm7ZkhEOO1XJct5cXpTHKACqcpI5G0wkGkUizSKAyfPeR/uIdS8wAXiPO+ kmtiAII2IHSR58I0wfdqaDQS98la8eWVSgmIAwtITVvgF4xBwzYhflujCS/Z4U6q8CP2 N3D2y1i9mMIBmXh4kmRdcQo2k88LKpST1zw6PVwFFkf0kj86tYZf4ultkDWNkrPLi59N tHWcrIJc1RBwRQ4ELdcXSuhUOlsqa9NmYJWTbvPLjSr7Enb9yMgJW735WFFDXJbYnTeu 1g0JMVykMAxwwXC+5aKn0a4WyTJs2Ct8fcFW5m8I1itGJNxbSAdswtpo01YLgjMoEYUq 7E/Q== 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=KsP/8alTgUwqy2thnwLB5km6OJZ8HPGr1q7CdsK84UQlezVfx0aoUYOZJegSlijPE8 BX+edtu4uOqCA652F/81R152aZ0/uPL/XL/edl50hTnY15M7CnN7APG99dxhm81rWniu bi6y2aRmzSQq6jY6V0SPKSqHs4AmSauzlkue5JuO+9XJiv1Bt4a/fUiFI2K45p0vZ3AI VnTISRP5aRiPPGQYBxdit4fghJoIAZLTueMxpzPbBWR+H1YPwqEIbDoTijFtJaEPpMj8 AZjXFZIrdxmT4lcvthXYB8s3EWwCuM6jhFZbRhP/1cFshslDQu+x//APWUW75R0OuV5Q 58+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LB1q0GDr; 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 k10-20020a170902d58a00b00176afa8c818si5676157plh.470.2022.09.06.07.38.32; Tue, 06 Sep 2022 07:38:53 -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=LB1q0GDr; 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 S241735AbiIFOVf (ORCPT + 99 others); Tue, 6 Sep 2022 10:21:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241914AbiIFOS7 (ORCPT ); Tue, 6 Sep 2022 10:18:59 -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 797F52A41B; Tue, 6 Sep 2022 06:49:59 -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 978B5B818DF; Tue, 6 Sep 2022 13:48:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02C86C433D7; Tue, 6 Sep 2022 13:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662472110; bh=g4OSy4eiWzd4GXoIulDPPUyvFbwo6gtuf8PChh14Lrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LB1q0GDrEdcgIeqgJjHsNCFI5nzwwKjkhOxtSJgp1L8qlFykTM6I2LHoPaD+Mfz7R +UwK2QKpyRmSjCbpNDf+fTGfxAd2TmAO/X4DpyLVGXs3TUkqvPBchQTLLPePmaxsdQ mEnL5zPC4LobsGwevqOvGEODCW6MIGSQZpzT96rk= 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.19 134/155] usb: gadget: mass_storage: Fix cdrom data transfers on MAC-OS Date: Tue, 6 Sep 2022 15:31:22 +0200 Message-Id: <20220906132835.131878343@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132829.417117002@linuxfoundation.org> References: <20220906132829.417117002@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;