From: Tristan Madani <tristmd@gmail.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@kernel.org>
Cc: linux-media@vger.kernel.org, stable@vger.kernel.org,
Tristan Madani <tristan@talencesecurity.com>
Subject: [PATCH 1/3] media: cx231xx: validate minimum transfer length in video handlers
Date: Sun, 18 Oct 2026 22:54:35 +0000 [thread overview]
Message-ID: <20261018225437.2655311-2-tristmd@gmail.com> (raw)
In-Reply-To: <20261018225437.2655311-1-tristmd@gmail.com>
From: Tristan Madani <tristan@talencesecurity.com>
cx231xx_isoc_copy() and cx231xx_bulk_copy() both save the last 4
bytes of the transfer buffer via memcpy(dma_q->partial_buf,
p_buffer + buffer_size - 4, 4). When the transfer length is less
than 4, the subtraction wraps to a large value and the memcpy reads
from an unintended memory offset.
Add a minimum length check to both handlers before processing.
Fixes: 64fbf4445526 ("[media] cx231xx: Added support for Carraera, Shelby, RDx_253S and VIDEO_GRABBER")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
drivers/media/usb/cx231xx/cx231xx-video.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index 70aa99fead278..76776cd6e5691 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -303,6 +303,9 @@ static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb)
buffer_size = urb->iso_frame_desc[i].actual_length;
bytes_parsed = 0;
+ if (buffer_size < 4)
+ continue;
+
if (dma_q->is_partial_line) {
/* Handle the case of a partial line */
sav_eav = dma_q->last_sav;
@@ -382,6 +385,9 @@ static inline int cx231xx_bulk_copy(struct cx231xx *dev, struct urb *urb)
buffer_size = urb->actual_length;
bytes_parsed = 0;
+ if (buffer_size < 4)
+ return 0;
+
if (dma_q->is_partial_line) {
/* Handle the case of a partial line */
sav_eav = dma_q->last_sav;
--
2.47.3
next prev parent reply other threads:[~2026-10-18 22:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 22:54 [PATCH 0/3] media: USB: validate transfer lengths in URB callbacks Tristan Madani
2026-10-18 22:54 ` Tristan Madani [this message]
2026-10-18 22:54 ` [PATCH 2/3] media: cx231xx: require minimum VBI transfer length Tristan Madani
2026-10-18 22:54 ` [PATCH 3/3] media: au0828: require minimum isochronous packet length Tristan Madani
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=20261018225437.2655311-2-tristmd@gmail.com \
--to=tristmd@gmail.com \
--cc=hverkuil@kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tristan@talencesecurity.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