mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: linux-media@vger.kernel.org, Sean Young <sean@mess.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Jarod Wilson <jarod@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 3/7] media: redrat3: Ensure we don't read beyond the end of the packet
Date: Fri, 10 Jul 2026 09:53:31 +0100	[thread overview]
Message-ID: <415546fcdb57253472f021f4094e9ef3228333a8.1783673420.git.sean@mess.org> (raw)
In-Reply-To: <cover.1783673420.git.sean@mess.org>

The length and offset is provided by the usb device, so it should be
validated.

Fixes: 2154be651b90 ("[media] redrat3: new rc-core IR transceiver device driver")
Signed-off-by: Sean Young <sean@mess.org>
---
 drivers/media/rc/redrat3.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index d2a805dbd3f3..424f8b9e4d17 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -358,8 +358,18 @@ static void redrat3_process_ir_data(struct redrat3_dev *rr3)
 
 	/* process each rr3 encoded byte into an int */
 	sig_size = be16_to_cpu(rr3->irdata.sig_size);
+
+	if (sig_size > RR3_MAX_SIG_SIZE) {
+		dev_err(dev, "length %u is incorrect\n", sig_size);
+		return;
+	}
+
 	for (i = 0; i < sig_size; i++) {
 		offset = rr3->irdata.sigdata[i];
+		if (offset >= RR3_DRIVER_MAXLENS) {
+			dev_err(dev, "offset %u is incorrect\n", offset);
+			return;
+		}
 		val = get_unaligned_be16(&rr3->irdata.lens[offset]);
 
 		/* we should always get pulse/space/pulse/space samples */
-- 
2.55.0


  parent reply	other threads:[~2026-07-10  8:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1783673420.git.sean@mess.org>
2026-07-10  8:53 ` [PATCH 1/7] media: streamzap: Add missing rc_unregister_device() Sean Young
2026-07-10  8:53 ` [PATCH 2/7] media: redrat3: Ensure rc device is freed if enable_detector() fails Sean Young
2026-07-10  8:53 ` Sean Young [this message]
2026-07-10  8:53 ` [PATCH 4/7] media: sunxi-cir: Ensure no more interrupts can occur before free Sean Young
2026-07-10  8:53 ` [PATCH 5/7] media: meson-ir-tx: Ensure clock is disabled on unbind Sean Young
2026-07-12 13:26   ` Martin Blumenstingl
2026-07-10  8:53 ` [PATCH 6/7] media: meson-ir-tx: Ensure rc_free_device() is called " Sean Young
2026-07-12 13:23   ` Martin Blumenstingl
2026-07-10  8:53 ` [PATCH 7/7] media: ir-hix5hd2: Ensure rdev is setup before interrupts are enabled Sean Young

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=415546fcdb57253472f021f4094e9ef3228333a8.1783673420.git.sean@mess.org \
    --to=sean@mess.org \
    --cc=jarod@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@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®