From: Igor Druzhinin via <qemu-devel@nongnu.org>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: <qemu-devel@nongnu.org>, <xen-devel@lists.xenproject.org>,
<sstabellini@kernel.org>, <anthony.perard@citrix.com>,
<paul@xen.org>, <mst@redhat.com>, <marcel.apfelbaum@gmail.com>,
<pbonzini@redhat.com>, <richard.henderson@linaro.org>,
<ehabkost@redhat.com>
Subject: Re: [PATCH] xen-mapcache: avoid a race on memory map while using MAP_FIXED
Date: Tue, 20 Apr 2021 10:45:03 +0100 [thread overview]
Message-ID: <8cd5ae50-dff8-2ccd-0036-f27b82242f74@citrix.com> (raw)
In-Reply-To: <YH6WfgdFpFaMYtvC@Air-de-Roger>
On 20/04/2021 09:53, Roger Pau Monné wrote:
> On Tue, Apr 20, 2021 at 04:35:02AM +0100, Igor Druzhinin wrote:
>> When we're replacing the existing mapping there is possibility of a race
>> on memory map with other threads doing mmap operations - the address being
>> unmapped/re-mapped could be occupied by another thread in between.
>>
>> Linux mmap man page recommends keeping the existing mappings in place to
>> reserve the place and instead utilize the fact that the next mmap operation
>> with MAP_FIXED flag passed will implicitly destroy the existing mappings
>> behind the chosen address. This behavior is guaranteed by POSIX / BSD and
>> therefore is portable.
>>
>> Note that it wouldn't make the replacement atomic for parallel accesses to
>> the replaced region - those might still fail with SIGBUS due to
>> xenforeignmemory_map not being atomic. So we're still not expecting those.
>>
>> Tested-by: Anthony PERARD <anthony.perard@citrix.com>
>> Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
>
> Should we add a 'Fixes: 759235653de ...' or similar tag here?
I was thinking about it and decided - no. There wasn't a bug here until
QEMU introduced usage of iothreads at the state loading phase.
Originally this process was totally single-threaded. And it's hard to
pinpoint the exact moment when it happened which is also not directly
related to the change here.
Igor
next prev parent reply other threads:[~2021-04-20 9:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-20 3:35 [PATCH] xen-mapcache: avoid a race on memory map while using MAP_FIXED Igor Druzhinin via
2021-04-20 3:39 ` no-reply
2021-04-20 9:51 ` Igor Druzhinin via
2021-04-20 10:51 ` Anthony PERARD via
2021-04-20 7:03 ` Paul Durrant
2021-04-20 8:53 ` Roger Pau Monné via
2021-04-20 9:45 ` Igor Druzhinin via [this message]
2021-04-20 10:26 ` Roger Pau Monné via
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=8cd5ae50-dff8-2ccd-0036-f27b82242f74@citrix.com \
--to=qemu-devel@nongnu.org \
--cc=anthony.perard@citrix.com \
--cc=ehabkost@redhat.com \
--cc=igor.druzhinin@citrix.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=richard.henderson@linaro.org \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.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 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).