All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Jan Beulich <jbeulich@suse.com>
Cc: hongyxia@amazon.co.uk, Julien Grall <jgrall@amazon.com>,
	Paul Durrant <paul@xen.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH for-4.15 2/4] xen/iommu: x86: Free the IOMMU page-tables with the pgtables.lock held
Date: Wed, 23 Dec 2020 14:01:59 +0000	[thread overview]
Message-ID: <295b32db-ddf7-3926-b4de-b0d3b78af316@xen.org> (raw)
In-Reply-To: <3148db2a-ff3f-5993-dd57-7f4376f2f0ad@suse.com>

Hi Jan,

On 23/12/2020 13:48, Jan Beulich wrote:
> On 22.12.2020 16:43, Julien Grall wrote:
>> From: Julien Grall <jgrall@amazon.com>
>>
>> The pgtables.lock is protecting access to the page list pgtables.list.
>> However, iommu_free_pgtables() will not held it. I guess it was assumed
>> that page-tables cannot be allocated while the domain is dying.
>>
>> Unfortunately, there is no guarantee that iommu_map() will not be
>> called while a domain is dying (it looks like to be possible from
>> XEN_DOMCTL_memory_mapping).
> 
> I'd rather disallow any new allocations for a dying domain, not
> the least because ...

Patch #4 will disallow such allocation. However...

> 
>> So it would be possible to be concurrently
>> allocate memory and free the page-tables.
>>
>> Therefore, we need to held the lock when freeing the page tables.
> 
> ... we should try to avoid holding locks across allocation /
> freeing functions wherever possible. >
> As to where to place a respective check - I wonder if we wouldn't
> be better off disallowing a majority of domctl-s (and perhaps
> other operations) on dying domains. Thoughts?

... this is still pretty racy because you need to guarantee that 
d->is_dying is seen by the other processors to prevent allocation.

As to whether we can forbid most of the domctl-s, I would agree this is 
a good move. But this doesn't remove the underlying problem here.

We are hoping that a top-level function will protect us against the 
race. Given the IOMMU code is quite deep in the callstack, this is 
something pretty hard to guarantee with future change.

So I still think we need a way to mitigate the issue.

Cheers,

-- 
Julien Grall


  reply	other threads:[~2020-12-23 14:02 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-22 15:43 [PATCH for-4.15 0/4] xen/iommu: Collection of bug fixes for IOMMU teadorwn Julien Grall
2020-12-22 15:43 ` [PATCH for-4.15 1/4] xen/iommu: Check if the IOMMU was initialized before tearing down Julien Grall
2020-12-23 13:27   ` Jan Beulich
2020-12-23 13:50     ` Julien Grall
2020-12-23 13:59       ` Jan Beulich
2020-12-23 14:51         ` Julien Grall
2020-12-23 14:58           ` Jan Beulich
2021-01-04  9:28   ` Paul Durrant
2021-01-04 14:33     ` Julien Grall
2020-12-22 15:43 ` [PATCH for-4.15 2/4] xen/iommu: x86: Free the IOMMU page-tables with the pgtables.lock held Julien Grall
2020-12-23 13:48   ` Jan Beulich
2020-12-23 14:01     ` Julien Grall [this message]
2020-12-23 14:16       ` Jan Beulich
2021-01-14 19:19       ` Julien Grall
2021-01-15 11:06         ` Jan Beulich
2021-01-15 15:18           ` Paul Durrant
2020-12-22 15:43 ` [PATCH for-4.15 3/4] [RFC] xen/iommu: x86: Clear the root page-table before freeing the page-tables Julien Grall
2020-12-23 14:12   ` Jan Beulich
2020-12-23 14:56     ` Julien Grall
2020-12-23 15:00       ` Jan Beulich
2020-12-23 15:16         ` Julien Grall
2020-12-23 16:11           ` Jan Beulich
2020-12-23 16:16             ` Julien Grall
2020-12-23 16:24               ` Jan Beulich
2020-12-23 16:29                 ` Julien Grall
2020-12-23 16:46                   ` Jan Beulich
2020-12-23 16:54                     ` Julien Grall
2020-12-23 17:02                       ` Jan Beulich
2020-12-23 17:26                         ` Julien Grall
2021-01-04  9:53                     ` Paul Durrant
2020-12-22 15:43 ` [PATCH for-4.15 4/4] xen/iommu: x86: Don't leak the IOMMU page-tables Julien Grall
2020-12-22 17:12   ` Julien Grall
2020-12-23 14:34   ` Jan Beulich
2020-12-23 16:07     ` Julien Grall
2020-12-23 16:15       ` Jan Beulich
2020-12-23 16:19         ` Julien Grall
2020-12-23 16:35           ` Jan Beulich
2021-01-14 18:53             ` Julien Grall
2021-01-15 11:24               ` Jan Beulich
2021-01-15 11:30                 ` Julien Grall

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=295b32db-ddf7-3926-b4de-b0d3b78af316@xen.org \
    --to=julien@xen.org \
    --cc=hongyxia@amazon.co.uk \
    --cc=jbeulich@suse.com \
    --cc=jgrall@amazon.com \
    --cc=paul@xen.org \
    --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.