From: David Vrabel <david.vrabel@citrix.com>
To: David Vrabel <david.vrabel@citrix.com>
Cc: Keir Fraser <keir@xen.org>, Jan Beulich <jbeulich@suse.com>,
xen-devel@lists.xen.org
Subject: Re: [PATCH 1/2] evtchn/fifo: don't spin indefinitely when setting LINK
Date: Wed, 20 Nov 2013 15:19:35 +0000 [thread overview]
Message-ID: <528CD307.9050607@citrix.com> (raw)
In-Reply-To: <1384256328-20223-2-git-send-email-david.vrabel@citrix.com>
On 12/11/13 11:38, David Vrabel wrote:
> From: David Vrabel <david.vrabel@citrix.com>
>
> A malicious or buggy guest can cause another domain to spin
> indefinitely by repeatedly writing to an event word when the other
> guest is trying to link a new event. The cmpxchg() in
> evtchn_fifo_set_link() will repeatedly fail and the loop may never
> terminate.
This was fixed by introducing the BUSY bit (see below), but I wonder if
another solution would be better.
The MASKED bits could all be moved into a separate bit array, guest
writes to set/clear the MASKED bit would never conflict with Xen
updating the main event word. The cmpxchg() loop is then trivially
bounded as the only valid writes by the guest are clear PENDING and
clear LINKED & LINK.
The masked array could be either:
1. In the same page as the event array. This would waste a big chunk of
the event array page though, Doubling the memory requirements.
2. Have a separate set of pages. EVTCHNOP_expand_array would be
extended to supply the GFN for the array page where necessary. For 2^17
events, 4 additional pages would be required for this masked array.
Thoughts?
David
> Fixing this requires a change to the ABI which is documented in draft
> H of the design.
>
> http://xenbits.xen.org/people/dvrabel/event-channels-H.pdf
>
> Since a well-behaved guest only makes a limited set of state changes,
> the loop can terminate early if the guest makes an invalid state
> transition.
>
> The guest may:
>
> - clear LINKED and LINK.
> - clear PENDING
> - set MASKED
> - clear MASKED
>
> It is valid for the guest to mask and unmask an event at any time so
> specify that it is not valid for a guest to clear MASKED if Xen is
> trying to update LINK. Indicate this to the guest with an additional
> BUSY bit in the event word. The guest must not clear MASKED if BUSY
> is set and it should spin until BUSY is cleared.
>
> The remaining valid writes (clear LINKED, clear PENDING, set MASKED,
> clear MASKED by Xen) will limit the number of failures of the
> cmpxchg() to at most 4. A clear of LINKED will also terminate the
> loop early. Therefore, the loop can then be limited to at most 4
> iterations.
>
> If the buggy or malicious guest does cause the loop to exit with
> LINKED set and LINK unset then that buggy guest will lose events.
next prev parent reply other threads:[~2013-11-20 15:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-12 11:38 [PATCHv4 0/2] Xen: FIFO-based event channel ABI fixes David Vrabel
2013-11-12 11:38 ` [PATCH 1/2] evtchn/fifo: don't spin indefinitely when setting LINK David Vrabel
2013-11-20 15:19 ` David Vrabel [this message]
2013-11-22 12:08 ` Jan Beulich
2013-11-12 11:38 ` [PATCH 2/2] evtchn/fifo: don't corrupt queues if an old tail moves queues David Vrabel
2013-11-15 13:15 ` David Vrabel
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=528CD307.9050607@citrix.com \
--to=david.vrabel@citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=xen-devel@lists.xen.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).