From: Arseniy Krasnov <avkrasnov@salutedevices.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Akash M <akash.m5@samsung.com>, <oxffffaa@gmail.com>,
<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<kernel@salutedevices.com>
Subject: Re: [PATCH v1] usb: gadget: f_fs: trim extra bytes from USB req
Date: Wed, 17 Dec 2025 16:56:53 +0300 [thread overview]
Message-ID: <d7ff6bd0-358a-4f84-a98c-ababe9c87082@salutedevices.com> (raw)
In-Reply-To: <2025121718-paltry-caress-43fd@gregkh>
17.12.2025 16:35, Greg Kroah-Hartman пишет:
> On Tue, Dec 09, 2025 at 04:44:11PM +0300, Arseniy Krasnov wrote:
>> In '__ffs_epfile_read_data()' number of bytes to copy to user iter is
>> returned by USB driver in field 'actual' of structure 'usb_request'
>> (see 'ffs_epfile_io_complete()'). Looks like some buggy driver may
>> return value larger than actual size of kernel buffer of such USB
>> request. This leads to the following crash (produced on 'dwc2' USB
>> driver). To prevent this, let's add extra check, which trims reported
>> request length.
>
> Why not fix the broken driver instead? That would resolve this
> properly, and not force the gadget code to work around obviously-broken
> kernel code.
>
I tried to debug driver (dwc2), but it is unclear how this happens (may be due to
some hw issues invalid length is reported). So as extra "protection" I added this
code to the common logic.
> We try to fix bugs at the root, not paper over them elsewhere.
>
> So what driver is causing this?
I reproduced once with drivers/usb/dwc2 driver. May be such check could be moved inside
this driver. In this case only single potential buggy driver will get workaround.
>
> thanks,
>
> greg k-h
Thanks
prev parent reply other threads:[~2025-12-17 14:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-09 13:44 Arseniy Krasnov
2025-12-17 13:35 ` Greg Kroah-Hartman
2025-12-17 13:56 ` Arseniy Krasnov [this message]
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=d7ff6bd0-358a-4f84-a98c-ababe9c87082@salutedevices.com \
--to=avkrasnov@salutedevices.com \
--cc=akash.m5@samsung.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel@salutedevices.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oxffffaa@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®