]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
si2157: Bounds check firmware
authorLaura Abbott <labbott@fedoraproject.org>
Wed, 30 Sep 2015 00:10:10 +0000 (21:10 -0300)
committerChuck Anderson <chuck.anderson@oracle.com>
Fri, 5 Feb 2016 03:28:16 +0000 (19:28 -0800)
Orabug: 22623808

commit a828d72df216c36e9c40b6c24dc4b17b6f7b5a76 upstream.

When reading the firmware and sending commands, the length
must be bounds checked to avoid overrunning the size of the command
buffer and smashing the stack if the firmware is not in the
expected format. Add the proper check.

Signed-off-by: Laura Abbott <labbott@fedoraproject.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit f7832ff91dd51ad2a43bd37846f9cef15b8c03e6)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
drivers/media/tuners/si2157.c

index d74ae26621ca531d458649c487fb9b883a73e00a..c5dbba5b5bc947b056ff228b600c2c41b3878487 100644 (file)
@@ -165,6 +165,10 @@ static int si2157_init(struct dvb_frontend *fe)
 
        for (remaining = fw->size; remaining > 0; remaining -= 17) {
                len = fw->data[fw->size - remaining];
+               if (len > SI2157_ARGLEN) {
+                       dev_err(&client->dev, "Bad firmware length\n");
+                       goto err_release_firmware;
+               }
                memcpy(cmd.args, &fw->data[(fw->size - remaining) + 1], len);
                cmd.wlen = len;
                cmd.rlen = 1;