Received: by 10.223.185.116 with SMTP id b49csp4175654wrg; Mon, 26 Feb 2018 12:34:57 -0800 (PST) X-Google-Smtp-Source: AH8x225UYkLdqS1CNThEfANowhzbt8wE0RdrzvspaZ4mHFTsxUTTQLNh64O4hpdCjlDmJx1tITPP X-Received: by 10.98.186.20 with SMTP id k20mr11696713pff.170.1519677297593; Mon, 26 Feb 2018 12:34:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519677297; cv=none; d=google.com; s=arc-20160816; b=nB9X3LrC1o1b3zuxc8VAihPT8XCeFehoTJLntq7tjNF6ztEYVm/Ex/4zLAO6bjKGJT 5GPLXtKer/3PXNFBdqseehf1vZ0AMBtGfXzLKLTj6BMf8qI2efS1uWDEYczaOR/Kvvx+ Ik7uD7Mir0pGZUR4+i1Va74ePkbSF3hFQB3yEnzLxYf2kSChncr2LJSwrSO9msjEKHAR 7deMucZjD6VKKIMJedtrsvFVlzpW1qyYkqUurz6ey0r6kecFLs7VoXbTaKyzTOSP5zZt 7YyRjrNZQuJd4BUFXhliL3U+2zBHtBTqdozEqOKulEVp3m+HYHIaQjPzqbI4u2PyXTQ9 SetA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=fHK4V7XOi1qV87bWvaSVehchrJ5VegbnUXpL0fohENM=; b=raczonlSFKx11LRgwmugfD36bNjXpaTtV/QQLybfgpPu9rSIwxGzHf3Sbx/9zSZthe wNCWc+k6mZrfsNgLKAr16jcoAX2ZZwtZnYy7fWfTQYWdcmJpMvjgeBSXloFH/sCpuWxp nJu/lz4b33uW0D/YCcc4toZe3xIYWEvXuVKPQLWprbM4Bh+teLonddoXSHPrU+r2ugKx nLcASQWT6wDat3JKvlGxau1Dmm7qBl0WjIXgC6aUBDB3aNCQ1pyXMYOupAtPAAF/yZij Gfd18bmF5QtUfonmCQH7Bog0ph8ThkjellrUHii1gzogqBI53r0SM2uEgw9yVs5JcR3Y QC7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31-v6si7248768plk.699.2018.02.26.12.34.41; Mon, 26 Feb 2018 12:34:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753929AbeBZU2U (ORCPT + 99 others); Mon, 26 Feb 2018 15:28:20 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37124 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752442AbeBZU2R (ORCPT ); Mon, 26 Feb 2018 15:28:17 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5538DE4B; Mon, 26 Feb 2018 20:28:16 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mayank Rana , Jack Pham , Felipe Balbi Subject: [PATCH 4.15 50/64] usb: gadget: f_fs: Process all descriptors during bind Date: Mon, 26 Feb 2018 21:22:27 +0100 Message-Id: <20180226202155.589853324@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180226202153.453363333@linuxfoundation.org> References: <20180226202153.453363333@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jack Pham commit 6cf439e0d37463e42784271179c8a308fd7493c6 upstream. During _ffs_func_bind(), the received descriptors are evaluated to prepare for binding with the gadget in order to allocate endpoints and optionally set up OS descriptors. However, the high- and super-speed descriptors are only parsed based on whether the gadget_is_dualspeed() and gadget_is_superspeed() calls are true, respectively. This is a problem in case a userspace program always provides all of the {full,high,super,OS} descriptors when configuring a function. Then, for example if a gadget device is not capable of SuperSpeed, the call to ffs_do_descs() for the SS descriptors is skipped, resulting in an incorrect offset calculation for the vla_ptr when moving on to the OS descriptors that follow. This causes ffs_do_os_descs() to fail as it is now looking at the SS descriptors' offset within the raw_descs buffer instead. _ffs_func_bind() should evaluate the descriptors unconditionally, so remove the checks for gadget speed. Fixes: f0175ab51993 ("usb: gadget: f_fs: OS descriptors support") Cc: stable@vger.kernel.org Co-Developed-by: Mayank Rana Signed-off-by: Mayank Rana Signed-off-by: Jack Pham Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_fs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -2976,10 +2976,8 @@ static int _ffs_func_bind(struct usb_con struct ffs_data *ffs = func->ffs; const int full = !!func->ffs->fs_descs_count; - const int high = gadget_is_dualspeed(func->gadget) && - func->ffs->hs_descs_count; - const int super = gadget_is_superspeed(func->gadget) && - func->ffs->ss_descs_count; + const int high = !!func->ffs->hs_descs_count; + const int super = !!func->ffs->ss_descs_count; int fs_len, hs_len, ss_len, ret, i; struct ffs_ep *eps_ptr;