cc35985
From 526fbce5b0e44c67a97c57656b3be9911f0a9b9b Mon Sep 17 00:00:00 2001
cc35985
From: Laura Abbott <labbott@fedoraproject.org>
cc35985
Date: Tue, 29 Sep 2015 16:59:20 -0700
cc35985
Subject: [PATCH 2/2] si2157: Bounds check firmware
cc35985
To: Antti Palosaari <crope@iki.fi>
cc35985
To: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
cc35985
Cc: Olli Salonen <olli.salonen@iki.fi>
cc35985
Cc: linux-media@vger.kernel.org
cc35985
Cc: linux-kernel@vger.kernel.org
cc35985
cc35985
When reading the firmware and sending commands, the length
cc35985
must be bounds checked to avoid overrunning the size of the command
cc35985
buffer and smashing the stack if the firmware is not in the
cc35985
expected format. Add the proper check.
cc35985
cc35985
Cc: stable@kernel.org
cc35985
Signed-off-by: Laura Abbott <labbott@fedoraproject.org>
cc35985
---
cc35985
 drivers/media/tuners/si2157.c | 4 ++++
cc35985
 1 file changed, 4 insertions(+)
cc35985
cc35985
diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
cc35985
index 5073821..ce157ed 100644
cc35985
--- a/drivers/media/tuners/si2157.c
cc35985
+++ b/drivers/media/tuners/si2157.c
cc35985
@@ -166,6 +166,10 @@ static int si2157_init(struct dvb_frontend *fe)
cc35985
 
cc35985
 	for (remaining = fw->size; remaining > 0; remaining -= 17) {
cc35985
 		len = fw->data[fw->size - remaining];
cc35985
+		if (len > SI2157_ARGLEN) {
cc35985
+			dev_err(&client->dev, "Bad firmware length\n");
cc35985
+			goto err_release_firmware;
cc35985
+		}
cc35985
 		memcpy(cmd.args, &fw->data[(fw->size - remaining) + 1], len);
cc35985
 		cmd.wlen = len;
cc35985
 		cmd.rlen = 1;
cc35985
-- 
cc35985
2.4.3
cc35985