From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Elkin Cruz <elkin@google.com>
Cc: Hans de Goede <hansg@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Antti Laakso <antti.laakso@linux.intel.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, irogers@google.com, stable@vger.kernel.org
Subject: Re: [PATCH 2/2] usb: misc: usbio: validate endpoint maxpacket sizes in usbio_probe()
Date: Mon, 30 Nov 2026 11:05:38 +0200 [thread overview]
Message-ID: <aw08Yowm9UFW7jNf@kekkonen.localdomain> (raw)
In-Reply-To: <20261125222828.1452483-3-elkin@google.com>
Hi Elkin,
On Wed, Nov 25, 2026 at 10:28:28PM +0000, Elkin Cruz wrote:
> usbio_probe() allocates ctrlbuf, txbuf, and rxbuf directly from the
> USB descriptor maxpacket sizes without verifying that each buffer can
> hold its packet header. A malformed USB descriptor with a smaller
> maxpacket size causes unsigned underflow in length checks and buffer
> overflows in usbio_ctrl_msg() and usbio_bulk_msg().
>
> Reject devices whose control or bulk endpoint maxpacket sizes are
> smaller than sizeof(struct usbio_ctrl_packet) or
> sizeof(struct usbio_bulk_packet), respectively.
I'd use another error code to signal this, e.g. -EIO or -ENXIO. -ENODEV
really says there's no device, and in this case the device is there (but
happens to be behaving somehow badly).
>
> Fixes: 121a0f839dbb ("usb: misc: Add Intel USBIO bridge driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Elkin Cruz <elkin@google.com>
> ---
> drivers/usb/misc/usbio.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/misc/usbio.c b/drivers/usb/misc/usbio.c
> index 6142a32c18a9..c9f22b600333 100644
> --- a/drivers/usb/misc/usbio.c
> +++ b/drivers/usb/misc/usbio.c
> @@ -591,6 +591,8 @@ static int usbio_probe(struct usb_interface *intf, const struct usb_device_id *i
>
> usbio->ctrl_pipe = usb_endpoint_num(&udev->ep0.desc);
> usbio->ctrlbuf_len = usb_maxpacket(udev, usbio->ctrl_pipe);
> + if (usbio->ctrlbuf_len < sizeof(struct usbio_ctrl_packet))
> + return -ENODEV;
> usbio->ctrlbuf = devm_kzalloc(dev, usbio->ctrlbuf_len, GFP_KERNEL);
> if (!usbio->ctrlbuf)
> return -ENOMEM;
> @@ -609,6 +611,8 @@ static int usbio_probe(struct usb_interface *intf, const struct usb_device_id *i
> usbio->txbuf_len = 63;
> else
> usbio->txbuf_len = usb_endpoint_maxp(ep_out);
> + if (usbio->txbuf_len < sizeof(struct usbio_bulk_packet))
> + return -ENODEV;
>
> usbio->txbuf = devm_kzalloc(dev, usbio->txbuf_len, GFP_KERNEL);
> if (!usbio->txbuf)
> @@ -620,6 +624,8 @@ static int usbio_probe(struct usb_interface *intf, const struct usb_device_id *i
> usbio->rxbuf_len = 63;
> else
> usbio->rxbuf_len = usb_endpoint_maxp(ep_in);
> + if (usbio->rxbuf_len < sizeof(struct usbio_bulk_packet))
> + return -ENODEV;
>
> usbio->rxbuf = devm_kzalloc(dev, usbio->rxbuf_len, GFP_KERNEL);
> if (!usbio->rxbuf)
--
Regards,
Sakari Ailus
prev parent reply other threads:[~2026-11-30 9:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 22:28 [PATCH 0/2] usb: misc: usbio: fix fatal URB resubmission and probe maxpacket bounds Elkin Cruz
2026-11-25 22:28 ` [PATCH 1/2] usb: misc: usbio: stop resubmitting bulk IN URB on fatal status Elkin Cruz
2026-11-25 22:28 ` [PATCH 2/2] usb: misc: usbio: validate endpoint maxpacket sizes in usbio_probe() Elkin Cruz
2026-11-30 9:05 ` Sakari Ailus [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=aw08Yowm9UFW7jNf@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=antti.laakso@linux.intel.com \
--cc=elkin@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=stable@vger.kernel.org \
/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®