From: Robin Murphy <robin.murphy@arm.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>,
Joerg Roedel <joro@8bytes.org>,
Magnus Damm <magnus.damm@gmail.com>
Cc: iommu@lists.linux-foundation.org,
linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu/ipmmu-vmsa: Fix crash on early domain free
Date: Wed, 7 Nov 2018 13:22:52 +0000 [thread overview]
Message-ID: <e4dcd8b2-768e-b11d-b6de-337b7e942050@arm.com> (raw)
In-Reply-To: <20181107131850.11584-1-geert+renesas@glider.be>
On 2018-11-07 1:18 pm, Geert Uytterhoeven wrote:
> If iommu_ops.add_device() fails, iommu_ops.domain_free() is still
> called, leading to a crash, as the domain was only partially
> initialized:
>
> ipmmu-vmsa e67b0000.mmu: Cannot accommodate DMA translation for IOMMU page tables
> sata_rcar ee300000.sata: Unable to initialize IPMMU context
> iommu: Failed to add device ee300000.sata to group 0: -22
> Unable to handle kernel NULL pointer dereference at virtual address 0000000000000038
> ...
> Call trace:
> ipmmu_domain_free+0x1c/0xa0
> iommu_group_release+0x48/0x68
> kobject_put+0x74/0xe8
> kobject_del.part.0+0x3c/0x50
> kobject_put+0x60/0xe8
> iommu_group_get_for_dev+0xa8/0x1f0
> ipmmu_add_device+0x1c/0x40
> of_iommu_configure+0x118/0x190
>
> Fix this by checking if the domain's context already exists, before
> trying to destroy it.
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> drivers/iommu/ipmmu-vmsa.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> index c4114b92652eb0c9..a8b2c649c1d1f1b9 100644
> --- a/drivers/iommu/ipmmu-vmsa.c
> +++ b/drivers/iommu/ipmmu-vmsa.c
> @@ -498,6 +498,9 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
>
> static void ipmmu_domain_destroy_context(struct ipmmu_vmsa_domain *domain)
> {
> + if (!domain->mmu)
> + return;
> +
> /*
> * Disable the context. Flush the TLB as required when modifying the
> * context registers.
>
next prev parent reply other threads:[~2018-11-07 13:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-07 13:18 [PATCH] iommu/ipmmu-vmsa: Fix crash on early domain free Geert Uytterhoeven
2018-11-07 13:22 ` Robin Murphy [this message]
2018-11-07 15:34 ` Joerg Roedel
2018-11-07 15:50 ` Geert Uytterhoeven
2018-11-07 16:03 ` Joerg Roedel
2018-11-07 16:17 ` Robin Murphy
2018-11-07 16:53 ` Joerg Roedel
2018-11-07 16:04 ` Joerg Roedel
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=e4dcd8b2-768e-b11d-b6de-337b7e942050@arm.com \
--to=robin.murphy@arm.com \
--cc=geert+renesas@glider.be \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.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;
as well as URLs for NNTP newsgroup(s).