[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-4.16 v3] gnttab: allow setting max version per-domain


  • To: Ian Jackson <iwj@xxxxxxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 28 Oct 2021 15:03:15 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TMjAYuXt5rsltQUWFAndqjAVZQiKlI8lpg4tgKFHseE=; b=cKppplmRiet98NaboJmmiSzwDtUOgFV+moarau+HQB57CW4JM+/KXZvJu/3KjoGLukvuRQn06ILpLcy9mpjhF2em0jEx9FYj+zkAuLhI6E/eXSCjVzG0eK3evbRyU4888Kmsl8WhxwgTB3rDD1NCEwOj6E8Ak43XPAUBxWnzCCMbzTP+m0sVBe9lA9KbnqxNTtlH2+bGaUsIHMpPgEmxvB4kqz26FFaHVDn3d606fJzuFNHBEZJ/HUMEFg5D1UcGw1DFsZ2b549MQC/vUR04abBoXEf9ceeTQku5bopcSbf/rb/haOtpGxfixBZN8Rz4CdDvpxEDPHbobOCTU2K1WA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j+9UhwpDcEBrmCkSTi7xBhPUVv7HdvG8FWUK6hpWWEY2W/qw3rHjft0EmV61CyowgoRE+TW6mWiKBPQ27iEOn6nI7GcO916ZinY26gqFMr7vf/jLOvJtEMikQLct9MJvjPovlfBnHN8/rQNbdhjWFigIuUNYiYG2ycoBS2teEPvSRdxsQIvESTTZeTuMfvV7XxkA5P2sqoWCJJEqe8QuRXGadiVrUD+XvQ2UWoDIbAnjdvbWa1qG4KPaN30f8ZvQ/zne3Db/w2dLenFgrxEkcqw5/KnA02A03HBd+PK9a+/tzrVttVog9J6cxaW06QsZLDNU2Dd7ocWgGnGy4/yMDw==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Christian Lindig <christian.lindig@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 28 Oct 2021 13:03:42 +0000
  • Ironport-data: A9a23:z1j846LdQbQaVM+EFE+RjZMlxSXFcZb7ZxGr2PjKsXjdYENSgzYGy jBOUW3QbqzcNjanKI9zYdji9xsPvZ7Vm9NnQVNlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokcxIn5BC5C5xZVG/fjgqoHUVaiUZUideSc+EH140Eo5y7Zg6mJVqYPR7z2l6 IuaT/L3YDdJ6xYsWo7Dw/vewP/HlK2aVAIw5jTSV9gS1LPtvyB94KYkDbOwNxPFrrx8RYZWc QphIIaRpQs19z91Yj+sfy2SnkciGtY+NiDW4pZatjTLbrGvaUXe345iXMfwZ3u7hB20jf9q4 c4TmqC2YisoMJ3mn+4bDgVxRnQW0a1uoNcrIFC6uM2XiUbHb2Ht07NlC0Re0Y8wo7gtRzsUr LpBdW5LPkvra+GemdpXTsF2gcsuNo/zNZ43sXB81zDJS/0hRPgvRo2Xu44EhWhh1qiiG97ca JY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II52 uN96sQY3BOy10gxOdGcgyEKq2nVdi4cU78qv40xCZPwjlZ50UlLZJHRB3Ok4JyLbNkQYEAmL iXN2fjHjrVYgEHDb2AyBT7G2u8E3cYCvxVDzVkjIVWVm4Wa2q9rjUMJqTlnHB5Iyhhn0v5oP jk5PkJ4EqyC4jN0iZURRGurAQxAWEWU90GZJ4HlT4EFo51EjlDwEVA=
  • Ironport-hdrordr: A9a23:A877kq4CR+UwD7/eRAPXwMzXdLJyesId70hD6qkXc20zTiX4rb HLoB1/73TJYVkqNE3I9eruBEDiexPhHPxOj7X5VI3KNGOKhILCFuBfxLqn7zr8GzDvss5xvJ 0QFpSW0eeAbmSSW/yKgjWFLw==
  • Ironport-sdr: Vqm9IcfZ7tUlYJjiWScSa81XyRJBkdzJQbW4OtfH3OJQR/jr5IuZ2SaubNtbm3W5uKcgosIvZP WlAaCoykwqLI9RVZ5G4XzxPbq6jvvoSCWvj9zhy1oWMaoMF0rcbXf6+8/WOTcDvCAaOwttt8n3 WWur3N/1/T0gNIlvtZdLU1LEXzU5+i1RsUmwZB2iZNdZ2MAAaUsEfcI2t2qe5YnguWu3ISBpnp 2a/fNy/0eoOgf4Yynn8rlqOudZXpVMW2rmdVRDxnnhTI5FotpU1lH8Swn9wy2sBtQiy2BmFBwr Ua4Yu03nkAD46BHrnnJzcvQW
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Oct 28, 2021 at 01:12:31PM +0100, Ian Jackson wrote:
> Roger Pau Monne writes ("[PATCH for-4.16 v3] gnttab: allow setting max 
> version per-domain"):
> > diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
> > index 55c4881205..21a39adb70 100644
> > --- a/docs/man/xl.cfg.5.pod.in
> > +++ b/docs/man/xl.cfg.5.pod.in
> > @@ -580,6 +580,12 @@ to have. This value controls how many pages of foreign 
> > domains can be accessed
> >  via the grant mechanism by this domain. The default value is settable via
> >  L<xl.conf(5)>.
> >  
> > +=item B<max_grant_version=NUMBER>
> > +
> > +Specify the maximum grant table version the domain is allowed to use. 
> > Current
> > +supported versions are 1 and 2. The default value is settable via
> > +L<xl.conf(5)>.
> 
> 
> Firstly, review from my maintainer hat:
> 
> In the lower levels of this stack, I'm not sure why you chose -1 for
> "default", when 0 is not (and never will be) used ?

No, I actually had plans to use 0 to signal no grant table support for
the guest, see:

https://lore.kernel.org/xen-devel/20210922082123.54374-7-roger.pau@xxxxxxxxxx/

> > diff --git a/tools/helpers/init-xenstore-domain.c 
> > b/tools/helpers/init-xenstore-domain.c
> > index 6836002f0b..7cd1aa8f7c 100644
> > --- a/tools/helpers/init-xenstore-domain.c
> > +++ b/tools/helpers/init-xenstore-domain.c
> > @@ -88,6 +88,7 @@ static int build(xc_interface *xch)
> >           */
> >          .max_grant_frames = 4,
> >          .max_maptrack_frames = 128,
> > +        .grant_opts = 1,
> >      };
> 
> I think this sets the max gnttab version for xenstore stub domains to
> 1 ?  That's not mentioned in your commit message or your release
> discussion.

Indeed. AFAICT MiniOS only supports grant table v1, and the grant
related parameters max_maptrack_frames and max_grant_frames are
already set based on DEFAULT_MAX_GRANTS and NR_GRANT_FRAMES
respectively as defined in MiniOS code.

Would you like me to this to the commit message:

"xenstored stubdomains are limited to grant table v1 because the
current MiniOS code used to build them only has support for grants v1.
There are existing limits set for xenstored stubdomains at creation
time that already match the defaults in MiniOS."

> 
> Secondly, the release question:
> 
> > Release rationale:
> > 
> > We have had a bunch of security issues involving grant table v2 (382,
> > 379, 268, 255) which could have been avoided by limiting the grant
> > table version available to guests. This can be currently done using a
> > global host parameter, but it's certainly more helpful to be able to
> > do it on a per domain basis from the toolstack.
> 
> Let me think this through.
> 
> Upside:
> 
> So the advantage is to have a mitigation for possible (but, perhaps,
> likely) future security bugs.  We don't change the default here, so
> the default configuration is still vulnerable.
> 
> We have this mitigation already but only on a per-host command line
> basis, so you (1) have to reboot (2) can't use it if you have any
> guests that need v2.  (2) is less of a problem than it sounds because
> even with the selective mitigation you will remain vulnerable to those
> guests.  So the main advantage is having to reboot the guests but not
> the hosts.
> 
> Downside:
> 
> > Changes to the hypervisor by this patch are fairly minimal, as there
> > are already checks for the max grant table version allowed, so the
> > main change there is moving the max grant table version limit inside
> > the domain struct and plumbing it through the toolstrack.
> 
> Right.
> 
> > I think the risk here is quite low for libxl/xl, because it's
> > extensively tested by osstest, so the main risk would be breaking the
> > Ocaml stubs, which could go unnoticed as those are not actually tested
> > by osstest.
> 
> I will want a review by ocaml folks.  Christian ?
> 
> In particular, I would like an opinion from the ocaml tooling
> maintainers about whether there is a risk of this feature breaking
> things *if it's not used*.
> 
> 
> I am not sure about the implications for migration.  Might using this
> cause migration to fail for some guests ?
> 
>    Note that when using the default grant version the specific max
>    version in use by the domain is not migrated. Any guests should be
>    able to cope with the max grant version changing across migrations,
>    and if a specific guest relies on a maximum grant version being
>    unconditionally available it should be specified on the configuration
>    file.
> 
> Only if the feature is *not* used, I guess.  Ie, this is the status
> quo.   So I don't think there is any release risk there.

This was raised by Jan in a previous version, the discussion can be
found here:

https://lore.kernel.org/xen-devel/0b58667f-b6bc-d5b5-2dd1-0c8996367319@xxxxxxxx/

The issue could arise if a guest that strictly needs grant v2 is
migrated from a host that has v2 as the default max version to another
box that has v1 as the max version. If the guest config file doesn't
explicitly specify that the guest requires grant v2 migration will
succeed, but the guest will likely fail to resume properly.

This is already the current behavior if a guest is migrated from a
host not having gnttab=max-ver set to one having gnttab=max-ver:1.

> 
> If this change does cause problems, it is deep throughout the stack,
> but not entangled with anything else, so I think we could revert it ?

I think so, unless we start piling a lot of other toolstack changes on
top it's unlikely to be a problem to revert.

> If we can get good answers to all of this, ideally I would like to see
> this committed by the end of tomorrow.  I plan to cut RC1 on Monday.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.