From: Marek Vasut <marex@denx.de>
To: Fabio Estevam <festevam@gmail.com>,
Szymon Heidrich <szymon.heidrich@gmail.com>,
Lukasz Majewski <lukma@denx.de>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH] Prevent buffer overflow on USB control endpoint
Date: Sun, 20 Nov 2022 15:43:30 +0100 [thread overview]
Message-ID: <030344eb-e9d8-2bf9-a2c3-f124a32f323b@denx.de> (raw)
In-Reply-To: <CAOMZO5DCtZUyXR7+qxbFtGxbrwiXizukFPVs1gjMH=UAxSOWSQ@mail.gmail.com>
On 11/17/22 12:50, Fabio Estevam wrote:
> [Adding Lukasz and Marek]
>
> On Thu, Nov 17, 2022 at 6:50 AM Szymon Heidrich
> <szymon.heidrich@gmail.com> wrote:
>>
>> Assure that the control endpoint buffer of size USB_BUFSIZ (4096)
>> can not be overflown during handling of USB control transfer
>> requests with wLength greater than USB_BUFSIZ.
>>
>> Signed-off-by: Szymon Heidrich <szymon.heidrich@gmail.com>
>> ---
>> drivers/usb/gadget/composite.c | 11 +++++++++++
>> 1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
>> index 2a309e624e..cb89f6dca9 100644
>> --- a/drivers/usb/gadget/composite.c
>> +++ b/drivers/usb/gadget/composite.c
>> @@ -1019,6 +1019,17 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
>> u8 endp;
>> struct usb_configuration *c;
>>
>> + if (w_length > USB_BUFSIZ) {
>> + if (ctrl->bRequestType & USB_DIR_IN) {
>> + /* Cast away the const, we are going to overwrite on purpose. */
>> + __le16 *temp = (__le16 *)&ctrl->wLength;
>> + *temp = cpu_to_le16(USB_BUFSIZ);
>> + w_length = USB_BUFSIZ;
Won't this end up sending corrupted packets in case they are longer than
USB_BUFSIZ ?
Where do such long packets come from ?
What is the test-case ?
next prev parent reply other threads:[~2022-11-20 14:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 20:00 USB Device buffer overflow Szymon Heidrich
2022-11-17 0:43 ` Sultan Khan
2022-11-17 0:56 ` Fabio Estevam
2022-11-17 9:48 ` [PATCH] Prevent buffer overflow on USB control endpoint Szymon Heidrich
2022-11-17 11:50 ` Fabio Estevam
2022-11-20 14:43 ` Marek Vasut [this message]
2022-11-20 15:29 ` Szymon Heidrich
2022-11-20 17:25 ` Marek Vasut
2022-11-20 17:42 ` Szymon Heidrich
2022-12-16 3:22 ` Marek Vasut
2022-12-19 18:52 ` Szymon Heidrich
2022-12-19 19:46 ` Marek Vasut
2022-11-28 9:21 ` Szymon Heidrich
2022-11-28 9:27 ` Marek Vasut
2022-12-12 9:55 ` Szymon Heidrich
2022-12-12 13:24 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=030344eb-e9d8-2bf9-a2c3-f124a32f323b@denx.de \
--to=marex@denx.de \
--cc=festevam@gmail.com \
--cc=lukma@denx.de \
--cc=szymon.heidrich@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.