Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp671366ybz; Fri, 1 May 2020 06:33:28 -0700 (PDT) X-Google-Smtp-Source: APiQypJ2kyICbrOjg/LA2o21sC2k9ARTLQoHjw+fzB0o/rviecKIHg24Gqr9IGX99y9tRJwBcsTI X-Received: by 2002:aa7:d4d3:: with SMTP id t19mr3448248edr.144.1588340008358; Fri, 01 May 2020 06:33:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588340008; cv=none; d=google.com; s=arc-20160816; b=z6rDMWE5N2ODSsFaHadsX7tvwrP9Q834TFVgjIG4zsRmurEGdvie63cMQ0VgI3uAYi pecKZeLnPYK9wFrqMquizG/Rv6xKTsa37VNhT2sdIptztt0k/QoQ/Mb39dDQX62jpAKG ytfocvyepT/gjx2Jyb719TzPU4gdrX/bMrdMBv0ZMuFNR7/Sn+6vvSQE6rV/pSWexEC4 TfWYiPhQ5wCUIiVjGJrOGi1oL5lKdKcwtTorJtQE8tINv+X9jgOo4F+KxdSa7w/3mSIB qCtmvHOjiE4xVajm9rrC0i6QhBGOtllebG/aZIif3eS03ZQnuYdBtY2W6y3Y7Fj1vg7I kj1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ipryXEox5eqwpVcAlH0vt+/lUrWqxisND0kbhG92c8Y=; b=Fi+RGzdG9oeAni7OcfeByoo81CbB2QWhrZ577ChzNBhMzD7BQ5I/fh047q1INsKKga uDy6DtMYtCusxjPqJO27Ty5Zjqly0iuIz2It4ramMSU28/+FqlwxtLMfLwwjCORbg8Ow 2bD9BFNQao8MRAEqoSU0ft0mfR1WhBzTzJVDMaguKwJNlcZV86UXMtl+GZs6yUxuuSfo O53y5tUm9AQ5ip9oFJ/+yEi5YBxG7N8FVqB8itddDVZymIo7FasBdwlN0zozJzcGGvH5 PGYNvVrcT7nhCzcVdVnVllcrvz+GAPfM+LqheCgql+kfQMvJNR8Y1NCH8WkL8/YTJKkW X4iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uMOZT6zO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t26si2272835edf.183.2020.05.01.06.33.05; Fri, 01 May 2020 06:33:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uMOZT6zO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728935AbgEANaT (ORCPT + 99 others); Fri, 1 May 2020 09:30:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:54206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728916AbgEANaP (ORCPT ); Fri, 1 May 2020 09:30:15 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B738D20757; Fri, 1 May 2020 13:30:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588339815; bh=nGTL1wh7egZT7n+lqj36JrU0NugYFFSPPXaJzaJsVU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uMOZT6zOfGxeSbhEKVWcwLDmB3DakeuP9hKNxKq2O3VkZDqjbtAp1NTla533XpOAB fxJx3e4apras6mI0UzNEWAIvZDvp1rUnuyz5e99R0Q5ozeupSESW3qyt+S4vf3XnLH jykflUaYLs2aSEY+pbzxkKwN1LHuhdQ9eiApuR5U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Udipto Goswami , Sriharsha Allenki , Manu Gautam Subject: [PATCH 4.9 58/80] usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset() Date: Fri, 1 May 2020 15:21:52 +0200 Message-Id: <20200501131531.023129637@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200501131513.810761598@linuxfoundation.org> References: <20200501131513.810761598@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Udipto Goswami commit 1c2e54fbf1da5e5445a0ab132c862b02ccd8d230 upstream. For userspace functions using OS Descriptors, if a function also supplies Extended Property descriptors currently the counts and lengths stored in the ms_os_descs_ext_prop_{count,name_len,data_len} variables are not getting reset to 0 during an unbind or when the epfiles are closed. If the same function is re-bound and the descriptors are re-written, this results in those count/length variables to monotonically increase causing the VLA allocation in _ffs_func_bind() to grow larger and larger at each bind/unbind cycle and eventually fail to allocate. Fix this by clearing the ms_os_descs_ext_prop count & lengths to 0 in ffs_data_reset(). Fixes: f0175ab51993 ("usb: gadget: f_fs: OS descriptors support") Cc: stable@vger.kernel.org Signed-off-by: Udipto Goswami Signed-off-by: Sriharsha Allenki Reviewed-by: Manu Gautam Link: https://lore.kernel.org/r/20200402044521.9312-1-sallenki@codeaurora.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_fs.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1701,6 +1701,10 @@ static void ffs_data_reset(struct ffs_da ffs->state = FFS_READ_DESCRIPTORS; ffs->setup_state = FFS_NO_SETUP; ffs->flags = 0; + + ffs->ms_os_descs_ext_prop_count = 0; + ffs->ms_os_descs_ext_prop_name_len = 0; + ffs->ms_os_descs_ext_prop_data_len = 0; }