Received: by 10.223.185.116 with SMTP id b49csp4168824wrg; Mon, 26 Feb 2018 12:27:17 -0800 (PST) X-Google-Smtp-Source: AH8x226cuxTYGo493myEwizojq+M1xvK08l1gk3dV0LwOmI0SB5QgmqxeiffRUM9exiEh8qnoW2k X-Received: by 2002:a17:902:5a1:: with SMTP id f30-v6mr11724701plf.124.1519676837767; Mon, 26 Feb 2018 12:27:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519676837; cv=none; d=google.com; s=arc-20160816; b=dryV8DpN3Mg7Uoo/RsAqbjrIKrKHuIOCgpw3Cr0qGEcZsEFStx8heGahQeSHEETjuy kF6M9esD5MXTRIy08Zm8oNFOArIw+f1Lf3cQ6DvcZODhvPrGsWIL6d47aSKTWW4e2xrT PWyZxwfeJqQEyRhiXNLO/+13e+AqAe3Jn2HSold/89Tjv2HFTKxmx/IEJwI4dciEmuS8 Ig850vRPWxKz3xGK5kUE1hnfEQGYGQOo3bel4nDLSGOqebjLqTsY1/6m880wHrq1uv9q SCPyWvJJ4vuXIUAYz69EMVPlAAtZomCVPJKZgbVDRBLPK5NDfHPmuenHU+eWe138d8Uy WrFw== 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=mzNUOYXkfpy/D8jjmm8LHAknQ98a1sg8jyHB2POTDrE=; b=0hXg0yygfGT5NbEqDv6Z7UIqsQo1UBbHgIyADIBFQS0NA2CBRd1jc92DZ4HUJv5n7C Rbz18kfku8s8T4+pgZx/A7T80HfQLeFW3DtD1zWjXwabZ7m7wyHe5Dw89/++H2gd8GpM Oeh/ab2zNgL7x1R+iMUzq7VYdlLDOJ4FkuB8xFo/Vv724hiy5wOUlxdNyMuDDOB52WmL xfyTvjeKGVS7GMH9as2aYiakidUZOw6zryvqk+o4QdAqvnH0zDNoAZKuGROF+EAc7SWn t6uxvBg5IadbCJy26Fl5ZoqYVjZ1r95puVrnyNY6lqMRt4WzXosdIR4PWZ+rrs4uja8J VvEg== 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 b5-v6si7023623plr.335.2018.02.26.12.27.00; Mon, 26 Feb 2018 12:27:17 -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 S1753309AbeBZU0A (ORCPT + 99 others); Mon, 26 Feb 2018 15:26:00 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35608 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752581AbeBZUZ4 (ORCPT ); Mon, 26 Feb 2018 15:25:56 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1C90CFE5; Mon, 26 Feb 2018 20:25:55 +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.14 43/54] usb: gadget: f_fs: Process all descriptors during bind Date: Mon, 26 Feb 2018 21:22:20 +0100 Message-Id: <20180226202146.529917777@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180226202144.375869933@linuxfoundation.org> References: <20180226202144.375869933@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.14-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 @@ -2980,10 +2980,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;