Received: by 10.223.185.116 with SMTP id b49csp4200797wrg; Mon, 26 Feb 2018 13:04:17 -0800 (PST) X-Google-Smtp-Source: AH8x2257eTbgNTaNzhyhpiUZFEf/KBSweg6bcbqrEprTbLx/sYbggRpQGIjntRisHBzU2WEIbFPo X-Received: by 10.101.75.70 with SMTP id k6mr9727593pgt.335.1519679057051; Mon, 26 Feb 2018 13:04:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519679057; cv=none; d=google.com; s=arc-20160816; b=jmedvWBMT6cIZReABQFjMLPABa54LiSB9WF6dzjkalEmnsGcyTEHklJWfPCGUkkx33 Aa+pCyhJr8kQMvlSu6nWqaJoWNrBGJm3HcUtBwvj8UH4IZu4ueQHgAoUsRhmRNLexxnK y0zCO8RyQLAbOgToxwbgle5/xMPypAtZwS94/D0wUU2RMoixS/E/mMOHTK4MM2SEsfbB 2FtVijn/nlXL4doYAxTUMcO4wIPQ0z10yc4y1/TPG0bq90BPTtV2bc62SoeSwKdvdoc1 aN6I7MHa79JQeUjBfD2yS96W+EzGCWI3dfYdxoqbZCqV3lq8vngFggUdg3ddfRhb7dJD rKYQ== 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=82/Tjeq97tGnNJhX3YqAGutBIEaO+nNGzbHQHK/jWuU=; b=iYJS9XADLoNY2evGqQyoVUmLjygV5anIT/K8rcL643z53oRTJl1w++djWC2Fvhl6YK G6vui/XKlavZm8RDGSUKrU+ARhZVtBU9PSjplkHVMniIZ6xkr2+yfG242HYBBqBIhukX 6TaVp1wEI7AIJSLgg/dhBKPwkWqxwR4r7WEhczjZXJy/UIICm/POJnBon03xQWKK5IOR WWISVCqp7PB627FCaJQBfbITQn+qeGXeYKTubZtsFFeLvQa8OSS5SZU4zJKPe4qr0MQk sy3kBSmCxSI2732p6s+MmOYHy4aXHFFZupj7kna9iH2724RHJBp4jDJ8Eh1hG23V+HRg JJ5A== 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 q10si2824141pfc.183.2018.02.26.13.04.00; Mon, 26 Feb 2018 13:04: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 S1752475AbeBZVCI (ORCPT + 99 others); Mon, 26 Feb 2018 16:02:08 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33922 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751511AbeBZUWH (ORCPT ); Mon, 26 Feb 2018 15:22:07 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 79F1610BB; Mon, 26 Feb 2018 20:21:48 +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.9 21/39] usb: gadget: f_fs: Process all descriptors during bind Date: Mon, 26 Feb 2018 21:20:42 +0100 Message-Id: <20180226201644.602974011@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180226201643.660109883@linuxfoundation.org> References: <20180226201643.660109883@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.9-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 @@ -2956,10 +2956,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;