All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Kevin Tian <kevin.tian@intel.com>
Subject: Re: [PATCH 3/6] VT-d: don't leak domid mapping on error path
Date: Mon, 15 Nov 2021 10:32:08 +0100	[thread overview]
Message-ID: <6d34fe38-6fed-5665-18dc-8e0999b5af2c@suse.com> (raw)
In-Reply-To: <YY57tg+oX/fN7FB3@Air-de-Roger>

On 12.11.2021 15:35, Roger Pau Monné wrote:
> On Fri, Nov 12, 2021 at 02:45:14PM +0100, Jan Beulich wrote:
>> On 12.11.2021 14:42, Roger Pau Monné wrote:
>>> On Fri, Nov 12, 2021 at 10:48:43AM +0100, Jan Beulich wrote:
>>>> 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.
>>>
>>> Would it help to place the domid cleanup in domain_context_unmap_one,
>>> as that would then cover calls from domain_context_unmap and the
>>> failure path in domain_context_mapping_one.
>>
>> I don't think that would work (without further convolution), because of
>> the up to 3 successive calls in DEV_TYPE_PCI handling. Cleanup may happen
>> only on the first map's error path or after the last unmap.
> 
> Hm, I see. And AFAICT that's because some devices that get assigned to
> a guest iommu context are not actually assigned to the guest (ie:
> pdev->domain doesn't get set, neither the device is added to the
> per-domain list), which makes them invisible to
> any_pdev_behind_iommu.
> 
> I dislike that the domid is added in domain_context_mapping_one, while
> the cleanup is not done in domain_context_unmap_one, and that some
> devices context could be using the domain id without being assigned to
> the domain.

This all isn't really pretty, is it? As Andrew has been saying (I think
more than once), ideally we'd rewrite IOMMU code from scratch. But I
don't see anyone having enough spare time to actually do so ...

Jan



  reply	other threads:[~2021-11-15  9:32 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 ` [PATCH 3/6] VT-d: don't leak domid mapping on error path Jan Beulich
2021-11-12 13:42   ` 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 [this message]
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=6d34fe38-6fed-5665-18dc-8e0999b5af2c@suse.com \
    --to=jbeulich@suse.com \
    --cc=kevin.tian@intel.com \
    --cc=roger.pau@citrix.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.