From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Alexandra Diupina <adiupina@astralinux.ru>
Cc: "Xiaowei Song" <songxiaowei@hisilicon.com>,
"Binghui Wang" <wangbinghui@hisilicon.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: Re: [PATCH v2] PCI: kirin: Fix buffer overflow
Date: Mon, 2 Sep 2024 20:29:14 +0200 [thread overview]
Message-ID: <20240902202914.2d399974@foz.lan> (raw)
In-Reply-To: <20240719122153.1987-1-adiupina@astralinux.ru>
Em Fri, 19 Jul 2024 15:21:53 +0300
Alexandra Diupina <adiupina@astralinux.ru> escreveu:
> In kirin_pcie_parse_port() pcie->num_slots is compared to
> pcie->gpio_id_reset size (MAX_PCI_SLOTS). Need to fix
> condition to pcie->num_slots + 1 >= MAX_PCI_SLOTS and move
> pcie->num_slots increment lower 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")
> Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru>
LGTM.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
> v2: some changes
> drivers/pci/controller/dwc/pcie-kirin.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
> index d5523f302102..deab1e653b9a 100644
> --- a/drivers/pci/controller/dwc/pcie-kirin.c
> +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> @@ -412,12 +412,12 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie,
> if (pcie->gpio_id_reset[i] < 0)
> continue;
>
> - 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");
> ret = -EINVAL;
> goto put_node;
> }
> + pcie->num_slots++;
>
> ret = of_pci_get_devfn(child);
> if (ret < 0) {
Thanks,
Mauro
prev parent reply other threads:[~2024-09-02 18:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-12 8:43 [PATCH] PCI: kirin: Fix buffer overflow Alexandra Diupina
2024-07-12 9:07 ` Mauro Carvalho Chehab
2024-07-19 12:21 ` [PATCH v2] " Alexandra Diupina
2024-09-02 14:14 ` Alexandra Diupina
2024-09-02 17:17 ` Krzysztof Wilczyński
2024-09-02 18:29 ` Mauro Carvalho Chehab [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240902202914.2d399974@foz.lan \
--to=mchehab+huawei@kernel.org \
--cc=adiupina@astralinux.ru \
--cc=bhelgaas@google.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=robh@kernel.org \
--cc=songxiaowei@hisilicon.com \
--cc=wangbinghui@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox