Patch "PCI: kirin: Fix buffer overflow in kirin_pcie_parse_port()" has been added to the 6.11-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    PCI: kirin: Fix buffer overflow in kirin_pcie_parse_port()

to the 6.11-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pci-kirin-fix-buffer-overflow-in-kirin_pcie_parse_po.patch
and it can be found in the queue-6.11 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 88e2c32dbc3eed490c82476afb70579c4e9597ba
Author: Alexandra Diupina <adiupina@xxxxxxxxxxxxx>
Date:   Tue Sep 3 14:58:23 2024 +0300

    PCI: kirin: Fix buffer overflow in kirin_pcie_parse_port()
    
    [ Upstream commit c500a86693a126c9393e602741e348f80f1b0fc5 ]
    
    Within kirin_pcie_parse_port(), the pcie->num_slots is compared to
    pcie->gpio_id_reset size (MAX_PCI_SLOTS) which is correct and would lead
    to an overflow.
    
    Thus, fix condition to pcie->num_slots + 1 >= MAX_PCI_SLOTS and move
    pcie->num_slots increment below the if-statement to avoid out-of-bounds
    array access.
    
    Found by Linux Verification Center (linuxtesting.org) with SVACE.
    
    Fixes: b22dbbb24571 ("PCI: kirin: Support PERST# GPIOs for HiKey970 external PEX 8606 bridge")
    Link: https://lore.kernel.org/linux-pci/20240903115823.30647-1-adiupina@xxxxxxxxxxxxx
    Signed-off-by: Alexandra Diupina <adiupina@xxxxxxxxxxxxx>
    [kwilczynski: commit log]
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@xxxxxxxxxx>
    Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
index 0a29136491b89..85a2c77b1835a 100644
--- a/drivers/pci/controller/dwc/pcie-kirin.c
+++ b/drivers/pci/controller/dwc/pcie-kirin.c
@@ -420,11 +420,11 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie,
 						     "unable to get a valid reset gpio\n");
 			}
 
-			pcie->num_slots++;
-			if (pcie->num_slots > MAX_PCI_SLOTS) {
+			if (pcie->num_slots + 1 >= MAX_PCI_SLOTS) {
 				dev_err(dev, "Too many PCI slots!\n");
 				return -EINVAL;
 			}
+			pcie->num_slots++;
 
 			ret = of_pci_get_devfn(child);
 			if (ret < 0) {




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux