From: David Lee <david.lee@trailofbits.com>
To: Lixu Zhang <lixu.zhang@intel.com>
Cc: David Lee <david.lee@trailofbits.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Dominik 'Disconnect3d' Czarnota
<dominik.czarnota@trailofbits.com>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] gpio: ljca: validate event payload length
Date: Fri, 17 Jul 2026 14:58:26 +0000 [thread overview]
Message-ID: <20260717145827.43889-1-david.lee@trailofbits.com> (raw)
ljca_gpio_event_cb() ignores the event length and trusts packet->num as
the number of two-byte GPIO records. A device can provide a complete USB
message whose nested count extends beyond the payload, making the callback
read beyond the receive allocation.
Require the payload to contain both the count byte and every record it
declares before iterating over the flexible array.
Fixes: c5a4b6fd31e8 ("gpio: Add support for Intel LJCA USB GPIO driver")
Assisted-by: Codex:gpt-5.5
Signed-off-by: David Lee <david.lee@trailofbits.com>
---
drivers/gpio/gpio-ljca.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpio/gpio-ljca.c b/drivers/gpio/gpio-ljca.c
index f32d1d237795..cb2b2623ccb1 100644
--- a/drivers/gpio/gpio-ljca.c
+++ b/drivers/gpio/gpio-ljca.c
@@ -290,6 +290,9 @@ static void ljca_gpio_event_cb(void *context, u8 cmd, const void *evt_data,
if (cmd != LJCA_GPIO_INT_EVENT)
return;
+ if (len < sizeof(*packet) ||
+ struct_size(packet, item, packet->num) > len)
+ return;
for (i = 0; i < packet->num; i++) {
generic_handle_domain_irq(ljca_gpio->gc.irq.domain,
--
2.43.0
reply other threads:[~2026-07-17 14:58 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=20260717145827.43889-1-david.lee@trailofbits.com \
--to=david.lee@trailofbits.com \
--cc=brgl@kernel.org \
--cc=dominik.czarnota@trailofbits.com \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lixu.zhang@intel.com \
--cc=sakari.ailus@linux.intel.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