* [PATCH] usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset()
@ 2020-04-02 4:32 Sriharsha Allenki
2020-04-02 4:40 ` Manu Gautam
0 siblings, 1 reply; 3+ messages in thread
From: Sriharsha Allenki @ 2020-04-02 4:32 UTC (permalink / raw)
To: balbi, gregkh, linux-usb, ugoswami
Cc: mgautam, jackp, stable, Sriharsha Allenki
From: Udipto Goswami <ugoswami@codeaurora.org>
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().
Change-Id: I3b292fe5386ab54b53df2b9f15f07430dc3df24a
Fixes: f0175ab51993 ("usb: gadget: f_fs: OS descriptors support")
Cc: stable@vger.kernel.org
Signed-off-by: Udipto Goswami <ugoswami@codeaurora.org>
Signed-off-by: Sriharsha Allenki <sallenki@codeaurora.org>
---
drivers/usb/gadget/function/f_fs.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index c81023b195c3..10f01f974f67 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1813,6 +1813,10 @@ static void ffs_data_reset(struct ffs_data *ffs)
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;
}
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset()
2020-04-02 4:32 [PATCH] usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset() Sriharsha Allenki
@ 2020-04-02 4:40 ` Manu Gautam
2020-04-02 4:47 ` Sriharsha Allenki
0 siblings, 1 reply; 3+ messages in thread
From: Manu Gautam @ 2020-04-02 4:40 UTC (permalink / raw)
To: Sriharsha Allenki, balbi, gregkh, linux-usb, ugoswami; +Cc: jackp, stable
On 4/2/2020 10:02 AM, Sriharsha Allenki wrote:
> From: Udipto Goswami <ugoswami@codeaurora.org>
>
> 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().
>
> Change-Id: I3b292fe5386ab54b53df2b9f15f07430dc3df24a
Please remove this.
> Fixes: f0175ab51993 ("usb: gadget: f_fs: OS descriptors support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Udipto Goswami <ugoswami@codeaurora.org>
> Signed-off-by: Sriharsha Allenki <sallenki@codeaurora.org>
> ---
> drivers/usb/gadget/function/f_fs.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index c81023b195c3..10f01f974f67 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -1813,6 +1813,10 @@ static void ffs_data_reset(struct ffs_data *ffs)
> 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;
> }
>
>
Reviewed-by: Manu Gautam <mgautam@codeaurora.org>
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset()
2020-04-02 4:40 ` Manu Gautam
@ 2020-04-02 4:47 ` Sriharsha Allenki
0 siblings, 0 replies; 3+ messages in thread
From: Sriharsha Allenki @ 2020-04-02 4:47 UTC (permalink / raw)
To: Manu Gautam, balbi, gregkh, linux-usb, ugoswami; +Cc: jackp, stable
Hi,
On 4/2/2020 10:10 AM, Manu Gautam wrote:
> On 4/2/2020 10:02 AM, Sriharsha Allenki wrote:
>> From: Udipto Goswami <ugoswami@codeaurora.org>
>>
>> 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().
>>
>> Change-Id: I3b292fe5386ab54b53df2b9f15f07430dc3df24a
> Please remove this.
Thanks Manu, sent v2 after removing it.
>> Fixes: f0175ab51993 ("usb: gadget: f_fs: OS descriptors support")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Udipto Goswami <ugoswami@codeaurora.org>
>> Signed-off-by: Sriharsha Allenki <sallenki@codeaurora.org>
>> ---
>> drivers/usb/gadget/function/f_fs.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
>> index c81023b195c3..10f01f974f67 100644
>> --- a/drivers/usb/gadget/function/f_fs.c
>> +++ b/drivers/usb/gadget/function/f_fs.c
>> @@ -1813,6 +1813,10 @@ static void ffs_data_reset(struct ffs_data *ffs)
>> 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;
>> }
>>
>>
> Reviewed-by: Manu Gautam <mgautam@codeaurora.org>
Thanks,
Sriharsha
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-02 4:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-02 4:32 [PATCH] usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset() Sriharsha Allenki
2020-04-02 4:40 ` Manu Gautam
2020-04-02 4:47 ` Sriharsha Allenki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox