]> git.hungrycats.org Git - linux/commitdiff
tty: rocket: Fix possible buffer overwrite on register_PCI
authorAnton Vasilyev <vasilyev@ispras.ru>
Fri, 27 Jul 2018 13:39:31 +0000 (16:39 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Sep 2018 20:48:57 +0000 (22:48 +0200)
[ Upstream commit 0419056ec8fd01ddf5460d2dba0491aad22657dd ]

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@ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/rocket.c

index 802eac7e561b85f1aa43601a7a9eb94b05d3cb62..2b8f2e0a4224b9d0fc7e4330573d098994a3232e 100644 (file)
@@ -1915,7 +1915,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);