[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180802150201.316e3361@alans-desktop>
Date: Thu, 2 Aug 2018 15:02:01 +0100
From: Alan Cox <gnomes@...rguk.ukuu.org.uk>
To: Anton Vasilyev <vasilyev@...ras.ru>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jslaby@...e.com>, linux-kernel@...r.kernel.org,
ldv-project@...uxtesting.org
Subject: Re: [PATCH] tty: rocket: Fix possible buffer overwrite on
register_PCI
On Fri, 27 Jul 2018 16:39:31 +0300
Anton Vasilyev <vasilyev@...ras.ru> wrote:
> If number of isa and pci boards exceed NUM_BOARDS on the path
> rp_init()->init_PCI()->register_PCI() then buffer overwrite occurs
> in register_PCI() on assign rcktpt_io_addr[i].
>
> The patch adds check on upper bound for index of registered
> board in register_PCI.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Anton Vasilyev <vasilyev@...ras.ru>
> ---
> drivers/tty/rocket.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
> index bdd17d2aaafd..b121d8f8f3d7 100644
> --- a/drivers/tty/rocket.c
> +++ b/drivers/tty/rocket.c
> @@ -1881,7 +1881,7 @@ static __init int register_PCI(int i, struct pci_dev *dev)
> ByteIO_t UPCIRingInd = 0;
>
> if (!dev || !pci_match_id(rocket_pci_ids, dev) ||
> - pci_enable_device(dev))
> + pci_enable_device(dev) || i >= NUM_BOARDS)
> return 0;
>
> rcktpt_io_addr[i] = pci_resource_start(dev, 0);
This is a real fix but you want to check i >= NUM_BOARDS before you
enable the device
Alan
Powered by blists - more mailing lists