From: Marc Zyngier <maz@kernel.org>
To: Dinghao Liu <dinghao.liu@zju.edu.cn>
Cc: "Toan Le" <toan@os.amperecomputing.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Duc Dang" <dhdang@apm.com>, "Tanmay Inamdar" <tinamdar@apm.com>,
linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: xgene-msi: Fix a potential UAF in xgene_msi_probe
Date: Mon, 25 Sep 2023 10:40:48 +0100 [thread overview]
Message-ID: <87o7hqmvz3.wl-maz@kernel.org> (raw)
In-Reply-To: <20230925062133.14170-1-dinghao.liu@zju.edu.cn>
On Mon, 25 Sep 2023 07:21:32 +0100,
Dinghao Liu <dinghao.liu@zju.edu.cn> wrote:
>
> xgene_allocate_domains() will call irq_domain_remove() to free
> msi->inner_domain on failure. However, its caller, xgene_msi_probe(),
> will also call irq_domain_remove() through xgene_msi_remove() on the
> same failure, which may lead to a use-after-free. Set the freed pointer
> to NULL to fix this issue.
>
> Fixes: dcd19de36775 ("PCI: xgene: Add APM X-Gene v1 PCIe MSI/MSIX termination driver")
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
> drivers/pci/controller/pci-xgene-msi.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/pci/controller/pci-xgene-msi.c b/drivers/pci/controller/pci-xgene-msi.c
> index 3ce38dfd0d29..c0192c5ff0f3 100644
> --- a/drivers/pci/controller/pci-xgene-msi.c
> +++ b/drivers/pci/controller/pci-xgene-msi.c
> @@ -253,6 +253,7 @@ static int xgene_allocate_domains(struct xgene_msi *msi)
>
> if (!msi->msi_domain) {
> irq_domain_remove(msi->inner_domain);
> + msi->inner_domain = NULL;
> return -ENOMEM;
> }
Why can't we just drop the irq_domain_remove() call here instead, and
simply rely on xgene_msi_remove() to do the right thing? Something
like the untested patch below.
Thanks,
M.
diff --git a/drivers/pci/controller/pci-xgene-msi.c b/drivers/pci/controller/pci-xgene-msi.c
index 0234e528b9a5..f98c9eb7bebf 100644
--- a/drivers/pci/controller/pci-xgene-msi.c
+++ b/drivers/pci/controller/pci-xgene-msi.c
@@ -251,10 +251,8 @@ static int xgene_allocate_domains(struct xgene_msi *msi)
&xgene_msi_domain_info,
msi->inner_domain);
- if (!msi->msi_domain) {
- irq_domain_remove(msi->inner_domain);
+ if (!msi->msi_domain)
return -ENOMEM;
- }
return 0;
}
--
Without deviation from the norm, progress is not possible.
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Dinghao Liu <dinghao.liu@zju.edu.cn>
Cc: "Toan Le" <toan@os.amperecomputing.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Duc Dang" <dhdang@apm.com>, "Tanmay Inamdar" <tinamdar@apm.com>,
linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: xgene-msi: Fix a potential UAF in xgene_msi_probe
Date: Mon, 25 Sep 2023 10:40:48 +0100 [thread overview]
Message-ID: <87o7hqmvz3.wl-maz@kernel.org> (raw)
In-Reply-To: <20230925062133.14170-1-dinghao.liu@zju.edu.cn>
On Mon, 25 Sep 2023 07:21:32 +0100,
Dinghao Liu <dinghao.liu@zju.edu.cn> wrote:
>
> xgene_allocate_domains() will call irq_domain_remove() to free
> msi->inner_domain on failure. However, its caller, xgene_msi_probe(),
> will also call irq_domain_remove() through xgene_msi_remove() on the
> same failure, which may lead to a use-after-free. Set the freed pointer
> to NULL to fix this issue.
>
> Fixes: dcd19de36775 ("PCI: xgene: Add APM X-Gene v1 PCIe MSI/MSIX termination driver")
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
> drivers/pci/controller/pci-xgene-msi.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/pci/controller/pci-xgene-msi.c b/drivers/pci/controller/pci-xgene-msi.c
> index 3ce38dfd0d29..c0192c5ff0f3 100644
> --- a/drivers/pci/controller/pci-xgene-msi.c
> +++ b/drivers/pci/controller/pci-xgene-msi.c
> @@ -253,6 +253,7 @@ static int xgene_allocate_domains(struct xgene_msi *msi)
>
> if (!msi->msi_domain) {
> irq_domain_remove(msi->inner_domain);
> + msi->inner_domain = NULL;
> return -ENOMEM;
> }
Why can't we just drop the irq_domain_remove() call here instead, and
simply rely on xgene_msi_remove() to do the right thing? Something
like the untested patch below.
Thanks,
M.
diff --git a/drivers/pci/controller/pci-xgene-msi.c b/drivers/pci/controller/pci-xgene-msi.c
index 0234e528b9a5..f98c9eb7bebf 100644
--- a/drivers/pci/controller/pci-xgene-msi.c
+++ b/drivers/pci/controller/pci-xgene-msi.c
@@ -251,10 +251,8 @@ static int xgene_allocate_domains(struct xgene_msi *msi)
&xgene_msi_domain_info,
msi->inner_domain);
- if (!msi->msi_domain) {
- irq_domain_remove(msi->inner_domain);
+ if (!msi->msi_domain)
return -ENOMEM;
- }
return 0;
}
--
Without deviation from the norm, progress is not possible.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-09-25 9:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-25 6:21 [PATCH] PCI: xgene-msi: Fix a potential UAF in xgene_msi_probe Dinghao Liu
2023-09-25 6:21 ` Dinghao Liu
2023-09-25 9:40 ` Marc Zyngier [this message]
2023-09-25 9:40 ` Marc Zyngier
2023-09-26 2:21 ` dinghao.liu
2023-09-26 2:21 ` dinghao.liu
-- strict thread matches above, loose matches on Subject: below --
2023-09-26 2:59 Dinghao Liu
2023-09-26 2:59 ` Dinghao Liu
2023-09-29 9:14 ` Marc Zyngier
2023-09-29 9:14 ` Marc Zyngier
2023-09-30 9:56 ` dinghao.liu
2023-09-30 9:56 ` dinghao.liu
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=87o7hqmvz3.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=bhelgaas@google.com \
--cc=dhdang@apm.com \
--cc=dinghao.liu@zju.edu.cn \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=robh@kernel.org \
--cc=tinamdar@apm.com \
--cc=toan@os.amperecomputing.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.