All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Kevin Tian <kevin.tian@intel.com>
Subject: [PATCH 3/6] VT-d: don't leak domid mapping on error path
Date: Fri, 12 Nov 2021 10:48:43 +0100	[thread overview]
Message-ID: <d4ca5274-dbbf-4cde-1a4b-0d7fe294c360@suse.com> (raw)
In-Reply-To: <a97adc3d-2808-1c87-8fd6-d6b24b83bd2b@suse.com>

While domain_context_mapping() invokes domain_context_unmap() in a sub-
case of handling DEV_TYPE_PCI when encountering an error, thus avoiding
a leak, individual calls to domain_context_mapping_one() aren't
similarly covered. Such a leak might persist until domain destruction.
Leverage that these cases can be recognized by pdev being non-NULL.

Fixes: dec403cc668f ("VT-d: fix iommu_domid for PCI/PCIx devices assignment")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
The Fixes: tag isn't strictly correct, as error handling had more severe
shortcomings at the time. But I wouldn't want to blame a commit
improving error handling to have introduced the leak.

--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1518,7 +1518,12 @@ int domain_context_mapping_one(
         rc = me_wifi_quirk(domain, bus, devfn, MAP_ME_PHANTOM_FUNC);
 
     if ( rc )
-        domain_context_unmap_one(domain, iommu, bus, devfn);
+    {
+        ret = domain_context_unmap_one(domain, iommu, bus, devfn);
+
+        if ( !ret && pdev && pdev->devfn == devfn )
+            check_cleanup_domid_map(domain, pdev, iommu);
+    }
 
     return rc;
 }



  parent reply	other threads:[~2021-11-12  9:48 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-12  9:46 [PATCH 0/6] VT-d: domain ID mapping improvements Jan Beulich
2021-11-12  9:47 ` [PATCH 1/6] VT-d: properly reserve DID 0 for caching mode IOMMUs Jan Beulich
2021-11-12 11:23   ` Roger Pau Monné
2021-11-12 12:07     ` Jan Beulich
2021-11-12 12:19       ` Roger Pau Monné
2021-11-15  5:13         ` Tian, Kevin
2021-11-12 12:21   ` Roger Pau Monné
2021-11-15  5:13   ` Tian, Kevin
2021-11-12  9:48 ` [PATCH 2/6] VT-d: split domid map cleanup check into a function Jan Beulich
2021-11-12 12:31   ` Roger Pau Monné
2021-11-15  5:16   ` Tian, Kevin
2021-11-12  9:48 ` Jan Beulich [this message]
2021-11-12 13:42   ` [PATCH 3/6] VT-d: don't leak domid mapping on error path Roger Pau Monné
2021-11-12 13:45     ` Jan Beulich
2021-11-12 14:35       ` Roger Pau Monné
2021-11-15  9:32         ` Jan Beulich
2021-11-15  5:21   ` Tian, Kevin
2021-11-12  9:49 ` [PATCH 4/6] VT-d: tidy domid map handling Jan Beulich
2021-11-15  5:51   ` Tian, Kevin
2021-11-12  9:49 ` [PATCH 5/6] VT-d: introduce helper to convert DID to domid_t Jan Beulich
2021-11-15  5:54   ` Tian, Kevin
2021-11-12  9:50 ` [PATCH 6/6] VT-d: avoid allocating domid_{bit,}map[] when possible Jan Beulich
2021-11-15  6:18   ` Tian, Kevin
2021-11-15  9:37     ` Jan Beulich

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=d4ca5274-dbbf-4cde-1a4b-0d7fe294c360@suse.com \
    --to=jbeulich@suse.com \
    --cc=kevin.tian@intel.com \
    --cc=xen-devel@lists.xenproject.org \
    /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.