Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6918814rwn; Tue, 13 Sep 2022 10:50:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Ya7QplwCTTTkIrJFOPIudLnLLR65BTgHcevWJ1PrIcmfykKj/QpEen5feE0GnXlHmg+6g X-Received: by 2002:a63:6bc5:0:b0:41c:26d2:81e2 with SMTP id g188-20020a636bc5000000b0041c26d281e2mr28213758pgc.522.1663091418044; Tue, 13 Sep 2022 10:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663091418; cv=none; d=google.com; s=arc-20160816; b=r9dwlwIy0Mwlp7E/bfzF05ewhqz9xoFvpYpKc8Eld+MRREdtH8HB/fG4vJIs3mazaN RrhL3saQQf+cLwI+4PaAi0rbElnsbZ4H115/aBgJbNFSBMripRkNMpI9sSim80s3C1g8 ko1I8rNHTfHLKhd/JXY1f3yGHKS2AsZzJU+U+a51vMwQr8cEJxjBV2cwxDfsnUttFxfV DW4uod+WPUV3N3STqbq0ueMOAdKeee42OsFAtwy+Afu2OZGLHruRCsrSA6Ee7/7Z3t76 UuIXLMQ+NLsGbf5uFIK668b6Znzo2Zcf1xjwPzL7ucba4FKwuWV57g3zK2+tkEYOemWz H97Q== 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=dOgguhg0KLD/AAO+t74vYNqq2jwRcCvlIUl9Byc4z8+28kIj/JdqVeJCQcjzwuX72Y C/Gs0QSi9n0mEX9YzlsoFsj2+Avl/vdAr20kIS+9vXPGT6uXQo3EsJt9kjgpSJYDDvxo T46zvFsGwqivR7b6C7hLvjeoR6/s6F7p5rA8FogpRKpcD/7GxjaoLvBKU+aBTuMWoeC1 bicArBGBhvKx1XPoq3tMf8ydjED/P34cypcDVs7uFhop4pfQ0cjGU8M+utAx8G0RudRR is4i1MeiUooNCowVFebyVvegivl2lRhMoT3wMrwBEKxPXMA8Bx8XVEaLktix11q4HtxJ x05w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zu3jQXXf; 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 s13-20020a17090302cd00b0017530ee43b7si12904882plk.339.2022.09.13.10.49.59; Tue, 13 Sep 2022 10:50:18 -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=zu3jQXXf; 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 S232494AbiIMRSw (ORCPT + 99 others); Tue, 13 Sep 2022 13:18:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232784AbiIMRRr (ORCPT ); Tue, 13 Sep 2022 13:17:47 -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 A8DE577551; Tue, 13 Sep 2022 09:05:19 -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 A6601B80F3B; Tue, 13 Sep 2022 14:27:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E80CEC433D6; Tue, 13 Sep 2022 14:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079251; bh=g4OSy4eiWzd4GXoIulDPPUyvFbwo6gtuf8PChh14Lrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zu3jQXXf7gKNdrpyrxabJgkq1optx+1R07RhSi6WTokuTsOq+wdn4GtOZtQx0mmPX 0EaRdf5KliYQ7B1KzZW3Lzarw1B0mKxM8mWXUUKlQ3BTbLt1qfmi+gmHV88A5dx6CX /NR9f+JF0GDts3cv8vAkSc/smOOWQS+4z2yNaSdU= 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.4 054/108] usb: gadget: mass_storage: Fix cdrom data transfers on MAC-OS Date: Tue, 13 Sep 2022 16:06:25 +0200 Message-Id: <20220913140355.953102576@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140353.549108748@linuxfoundation.org> References: <20220913140353.549108748@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;