Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4516753rwb; Tue, 6 Sep 2022 08:34:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Gi5Ucc7YbBouI7JpLYrwxFWO+F22GRKiLRzRFDF1V2hBRaTS9/kXkHlh48QByxPKELryU X-Received: by 2002:a17:90a:53a4:b0:1fa:97eb:6f0a with SMTP id y33-20020a17090a53a400b001fa97eb6f0amr25659643pjh.54.1662478455899; Tue, 06 Sep 2022 08:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662478455; cv=none; d=google.com; s=arc-20160816; b=nOvKAw2MXjtfeU9nXG5+c5XlrjFZ1zaxDfhby8FCbTRTziR7hhl/YRnlybl+CafuhW 87MXnZQwL2RoW8OfRniHhcJ91PdGq4vB3TS9yu1MUuQPJMefsJ3PsTp/N/ud2AzTDk3M q5Et93TrpqEuQ0x9WvaBifk+5gW4URNO35vEKfTTe1f4A6Yo5GCM0RmIJHKAg9kvyZ4R 6U5Fr3t52kWdBX/BKpnhgtpIfoViFZNu7ABhpB0DIQcaeViGX6Cg969fYpMon7v9lIdz Q3rDBrKgloPnRZRDx3bU2eALFDGzg3YrUEk0SHNGNjR4gNZ80jeDs8VmRCqkYZ5o1FPi Pv5w== 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=DG1L8eqIF2RC+Uh14g+mKHqCDTcOGUv41ROLJPFfxubsejKTgS5407zl122mlqUraI tMsD12cJGumz+qfFWxd9O119lEfaRbMAF/X8ThwP3OQwkAQEL+MdpZKLKu2DwdPhklY2 Vj53AHRz2UI40pRoJXFq9LrNGr6gl00NOn+/+87rrz+8tVIb5RCUjbVCw3+UdyVYqa2V y7gFCVVp4hOyPI8orOwfyKB6I9E+HKq2Ibs3g+hndl5HyTokf4OuoztiPVBhZntetSsY cgy1YsxMN2n+4yQQF4UCL4fphCZQSwBUzjx/kXSn7p3slotaEzGVzq4SJO1b4osXHd/s nNLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jFxTJI2y; 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 c124-20020a624e82000000b0053e1d872a91si2483786pfb.83.2022.09.06.08.34.03; Tue, 06 Sep 2022 08:34:15 -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=jFxTJI2y; 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 S239290AbiIFNzU (ORCPT + 99 others); Tue, 6 Sep 2022 09:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239082AbiIFNwp (ORCPT ); Tue, 6 Sep 2022 09:52:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1CCE1838B; Tue, 6 Sep 2022 06:40:27 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1D15261545; Tue, 6 Sep 2022 13:40:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E648C433D6; Tue, 6 Sep 2022 13:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471619; bh=g4OSy4eiWzd4GXoIulDPPUyvFbwo6gtuf8PChh14Lrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jFxTJI2y9yQ2E9dVg7pUU2ETlBi6l91sSH2E7MZJTw/2lyDKJiHOCM5Aoo8rL14BZ sMB7JuO9deIp+Wz/x8NF5uzghrsk+my5F8hvV+qSWQmiJW0Ipk1uI+fdBP2yX6iUxK bjTy5JyOIub4dv/YvFCqT0Ri59NLJKv4CmU6vY2s= 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.15 088/107] usb: gadget: mass_storage: Fix cdrom data transfers on MAC-OS Date: Tue, 6 Sep 2022 15:31:09 +0200 Message-Id: <20220906132825.537477342@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132821.713989422@linuxfoundation.org> References: <20220906132821.713989422@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;