From: Hyunjung Ko <hj351016@gmail.com>
To: Linus Walleij <linusw@kernel.org>, Bartosz Golaszewski <brgl@kernel.org>
Cc: Mary Strodl <mstrodl@csh.rit.edu>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Hyunjung Ko <hj351016@gmail.com>
Subject: [PATCH] gpio: mpsse: reject bulk-in endpoints smaller than 3 bytes
Date: Tue, 17 Nov 2026 19:41:10 +0900 [thread overview]
Message-ID: <20261117104110.240112-1-hj351016@gmail.com> (raw)
mpsse_read() reads min(len + 2, wMaxPacketSize) bytes and then copies
len_actual - 2 bytes to the caller. A device that declares a bulk-in
endpoint with wMaxPacketSize 1 completes the read with len_actual 1, so
the copy length becomes -1 and memcpy() runs far past the one byte
buffer on the caller's stack and past bulk_in_buf:
memcpy: detected buffer overflow: 18446744073709551615 byte write of buffer size 1
WARNING: lib/string_helpers.c:1036 at __fortify_report+0x6e/0xc0
Call Trace:
__fortify_panic+0xd/0x10
gpio_mpsse_get_multiple+0x767/0x780
gpio_mpsse_gpio_get+0xa2/0xf0
gpiod_get_raw_value_commit+0xf8/0x1f0
gpiod_get_value_cansleep+0x1e/0xa0
value_show+0x42/0x90
Reproduced with dummy_hcd and raw-gadget. A read needs room for the two
status bytes plus at least one data byte, so refuse to bind otherwise.
Fixes: c46a74ff05c0 ("gpio: add support for FTDI's MPSSE as GPIO")
Cc: stable@vger.kernel.org
Signed-off-by: Hyunjung Ko <hj351016@gmail.com>
---
drivers/gpio/gpio-mpsse.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpio/gpio-mpsse.c b/drivers/gpio/gpio-mpsse.c
index 61c5ca96314b..3ad7048f009f 100644
--- a/drivers/gpio/gpio-mpsse.c
+++ b/drivers/gpio/gpio-mpsse.c
@@ -676,6 +676,10 @@ static int gpio_mpsse_probe(struct usb_interface *interface,
if (err)
return err;
+ /* Every read carries two status bytes ahead of the data */
+ if (usb_endpoint_maxp(priv->bulk_in) < 3)
+ return -EINVAL;
+
priv->bulk_in_buf = devm_kmalloc(dev, usb_endpoint_maxp(priv->bulk_in),
GFP_KERNEL);
if (!priv->bulk_in_buf)
--
2.43.0
reply other threads:[~2026-11-17 10:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261117104110.240112-1-hj351016@gmail.com \
--to=hj351016@gmail.com \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mstrodl@csh.rit.edu \
--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®