Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6775947rwn; Tue, 13 Sep 2022 08:52:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ggjX2lNOox1Q9dgk4yeCF8cLC7S0U1E56mOZBbDVOezxIfHLvnMs4yBgoxtOyA8X5V0Rt X-Received: by 2002:a17:906:5d04:b0:77f:ca9f:33d1 with SMTP id g4-20020a1709065d0400b0077fca9f33d1mr3624566ejt.526.1663084375950; Tue, 13 Sep 2022 08:52:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663084375; cv=none; d=google.com; s=arc-20160816; b=PSpB7G/NhRIs1c3NswnIBPeVo+LVrkgvqe31opqyfoyOvvBy++wTxjKyWuGEJ0svrL /UP2otLxvuUmK+XsF4zMYAMgiDNRUmWJurs0VbRH1U0jnfZ/DSt5CyHGxsiB1L0x+A4a Of8MeLJr09+hswlEsuJLcTYLBHt5W+XiV+FVRAG3THTelkukf79l3Yt2mMeChcJmYkSz G9dglHFIh9kpcHHbwwff7uTII0ehFKlmedJ44wSzm8iv53FnN00rdyXtrESiXRWjZYmv ZRQ9e/Hm4HcFudvppSIPt7jbLlpRt2jVsALZFgYEiSLh/B1sQFyu7uJz8u3CLqcbpXBR Avzg== 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=Ehnkg8OSwAxXMtS3cxmM6Ajpv8K1fLux+UXCGmyboLw=; b=wk2AfTpoWVfd+4RjAih82NC+E9ynd+F0Ls2+ZZOC+MvfvMvEmlPYJyTn0eLJEftk2K nRPs1Jwyy2lmsgNOizYpWOSUDtPsMw/lwtKHyRurPal0d7HwNbnR1INk1HyBYnGkklWc rWYtHZV89Sd/pzpzVSFCz8JFANSI3KW/1YkREJ1WZDChRzVFbWczDa8G1KI9UsRFTJtK KhuRqJFBxd5xtqOWuB2UdsiOp8AMtbpKGEYun8PIM8gOU/akxD7nvtLJ8XkTjbtTnb2L Ki007ueurCiLZgYOBzR4i1ycPHqGPJIed57UgH1G/K51uDZYRtfU334LMyWYgYZhpuEf Fb2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="yBUJAR/t"; 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 nd21-20020a170907629500b0074b26b6bbbcsi10087007ejc.419.2022.09.13.08.52.30; Tue, 13 Sep 2022 08:52:55 -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="yBUJAR/t"; 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 S236411AbiIMP2Y (ORCPT + 99 others); Tue, 13 Sep 2022 11:28:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236179AbiIMP1B (ORCPT ); Tue, 13 Sep 2022 11:27:01 -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 360007D7BA; Tue, 13 Sep 2022 07:38:49 -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 CABEBB80F9D; Tue, 13 Sep 2022 14:36:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FFF4C433D7; Tue, 13 Sep 2022 14:36:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079799; bh=0PyzWKGgacvE+hrA7uAAPic9Xb5y/v5fYZvJrGxE2Bo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yBUJAR/tCzJHT7YOOtlsAE7fKI38Y5gmkcI3cFBnX4ZgYkVAN6X3DBuuYm9XAT/+U avNoucH3afzMDTSRiFhJq5m9CeYLr3OqpfJlaoFbKNoielWcb5pIr7BzCK05F2B7gM QylisbVxc1DhLoMX7y8WjKViIP8u/MuIYrWVUwoM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Krishna Kurapati Subject: [PATCH 4.9 18/42] usb: gadget: mass_storage: Fix cdrom data transfers on MAC-OS Date: Tue, 13 Sep 2022 16:07:49 +0200 Message-Id: <20220913140343.184916758@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140342.228397194@linuxfoundation.org> References: <20220913140342.228397194@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 @@ -298,8 +298,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;