[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1529279007.2289.246.camel@codethink.co.uk>
Date: Mon, 18 Jun 2018 00:43:27 +0100
From: Ben Hutchings <ben.hutchings@...ethink.co.uk>
To: Colin Ian King <colin.king@...onical.com>,
Hans Verkuil <hans.verkuil@...co.com>,
Mauro Carvalho Chehab <mchehab@...pensource.com>
Cc: stable@...r.kernel.org,
Sasha Levin <alexander.levin@...rosoft.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 4.4 246/268] media: cx25821: prevent out-of-bounds read
on array card
On Mon, 2018-05-28 at 12:03 +0200, Greg Kroah-Hartman wrote:
> 4.4-stable review patch. If anyone has any objections, please let me know.
>
> ------------------
>
> From: Colin Ian King <colin.king@...onical.com>
>
> [ Upstream commit 67300abdbe9f1717532aaf4e037222762716d0f6 ]
>
> Currently an out of range dev->nr is detected by just reporting the
> issue and later on an out-of-bounds read on array card occurs because
> of this. Fix this by checking the upper range of dev->nr with the size
> of array card (removes the hard coded size), move this check earlier
> and also exit with the error -ENOSYS to avoid the later out-of-bounds
> array read.
I don't think this is a correct fix.
The card[] array and module parameter appear to be completely
redundant. Instead of arbitrarily limiting the number of cards that
the driver can bind to, we should remove them.
Ben.
> Detected by CoverityScan, CID#711191 ("Out-of-bounds-read")
>
> Fixes: commit 02b20b0b4cde ("V4L/DVB (12730): Add conexant cx25821 driver")
>
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
> Signed-off-by: Hans Verkuil <hans.verkuil@...co.com>
> [hans.verkuil@...co.com: %ld -> %zd]
> Signed-off-by: Mauro Carvalho Chehab <mchehab@...pensource.com>
> Signed-off-by: Sasha Levin <alexander.levin@...rosoft.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> ---
> drivers/media/pci/cx25821/cx25821-core.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> --- a/drivers/media/pci/cx25821/cx25821-core.c
> +++ b/drivers/media/pci/cx25821/cx25821-core.c
> @@ -871,6 +871,10 @@ static int cx25821_dev_setup(struct cx25
> dev->nr = ++cx25821_devcount;
> sprintf(dev->name, "cx25821[%d]", dev->nr);
>
> + if (dev->nr >= ARRAY_SIZE(card)) {
> + CX25821_INFO("dev->nr >= %zd", ARRAY_SIZE(card));
> + return -ENODEV;
> + }
> if (dev->pci->device != 0x8210) {
> pr_info("%s(): Exiting. Incorrect Hardware device = 0x%02x\n",
> __func__, dev->pci->device);
> @@ -886,9 +890,6 @@ static int cx25821_dev_setup(struct cx25
> dev->channels[i].sram_channels = &cx25821_sram_channels[i];
> }
>
> - if (dev->nr > 1)
> - CX25821_INFO("dev->nr > 1!");
> -
> /* board config */
> dev->board = 1; /* card[dev->nr]; */
> dev->_max_num_decoders = MAX_DECODERS;
--
Ben Hutchings, Software Developer Codethink Ltd
https://www.codethink.co.uk/ Dale House, 35 Dale Street
Manchester, M1 2HF, United Kingdom
Powered by blists - more mailing lists