Skip to contentSkip to conversation

xen: add option to disable GNTTABOP_transfer

PATCH In review Juergen Gross 3 participants 13 messages Feb 3, 2022 – Feb 25, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 xen: add option to disable GNTTABOP_transfer

The grant table operation GNTTABOP_transfer is meant to be used in PV device backends, and it hasn't been used in Linux since the old Xen-o-Linux days.

Add a command line sub-option to the "gnttab" option for disabling the GNTTABOP_transfer functionality.

---
V2:
- make option available for CONFIG_PV only (Jan Beulich)
- return -EOPNOTSUPP instead of -ENOSYS (Jan Beulich)

---
 docs/misc/xen-command-line.pandoc |  8 ++++++--
 xen/common/grant_table.c          | 12 ++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)
docs/misc/xen-command-line.pandoc +6 -2
index 6b3da6ddc1..44232b94c5 100644
@@ -1167,9 +1167,9 @@ does not provide `VM_ENTRY_LOAD_GUEST_PAT`.
 Specify which console gdbstub should use. See **console**.
 
 ### gnttab
-> `= List of [ max-ver:<integer>, transitive=<bool> ]`
+> `= List of [ max-ver:<integer>, transitive=<bool>, transfer=<bool> ]`
 
-> Default: `gnttab=max-ver:2,transitive`
+> Default: `gnttab=max-ver:2,transitive,transfer`
 
 Control various aspects of the grant table behaviour available to guests.
 
@@ -1178,6 +1178,10 @@ version are 1 and 2.
 * `transitive` Permit or disallow the use of transitive grants.  Note that the
 use of grant table v2 without transitive grants is an ABI breakage from the
 guests point of view.
+* `transfer` Permit or disallow the GNTTABOP_transfer operation of the
+grant table hypercall.  Note that disallowing GNTTABOP_transfer is an ABI
+breakage from the guests point of view.  This option is only available on
+hypervisors configured to support PV guests.
 
 The usage of gnttab v2 is not security supported on ARM platforms.
 
xen/common/grant_table.c +12 -0
index ed1e2fabce..57dfc54994 100644
@@ -181,6 +181,11 @@ static int parse_gnttab_max_maptrack_frames(const char *arg)
 
 unsigned int __read_mostly opt_gnttab_max_version = GNTTAB_MAX_VERSION;
 static bool __read_mostly opt_transitive_grants = true;
+#ifdef CONFIG_PV
+static bool __ro_after_init opt_grant_transfer = true;
+#else
+#define opt_grant_transfer false
+#endif
 
 static int __init parse_gnttab(const char *s)
 {
@@ -204,6 +209,10 @@ static int __init parse_gnttab(const char *s)
         }
         else if ( (val = parse_boolean("transitive", s, ss)) >= 0 )
             opt_transitive_grants = val;
+#ifndef opt_grant_transfer
+        else if ( (val = parse_boolean("transfer", s, ss)) >= 0 )
+            opt_grant_transfer = val;
+#endif
         else
             rc = -EINVAL;
 
@@ -2233,6 +2242,9 @@ gnttab_transfer(
     unsigned int max_bitsize;
     struct active_grant_entry *act;
 
+    if ( !opt_grant_transfer )
+        return -EOPNOTSUPP;
+
     for ( i = 0; i < count; i++ )
     {
         bool_t okay;
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 2/2 xen/include/public: deprecate GNTTABOP_transfer

Add a comment to include/public/grant_table.h that GNTTABOP_transfer is deprecated, in order to discourage new use cases.

---
v2:
- new patch

---
 xen/include/public/grant_table.h | 2 ++
 1 file changed, 2 insertions(+)
xen/include/public/grant_table.h +2 -0
index 7934d7b718..7fbd1c6d10 100644
@@ -417,6 +417,8 @@ DEFINE_XEN_GUEST_HANDLE(gnttab_dump_table_t);
  * GNTTABOP_transfer: Transfer <frame> to a foreign domain. The foreign domain
  * has previously registered its interest in the transfer via <domid, ref>.
  *
+ * This operation is deprecated! Please don't add new use cases!
+ *
  * Note that, even if the transfer fails, the specified page no longer belongs
  * to the calling domain *unless* the error is GNTST_bad_page.
  *
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v2 2/2] xen/include/public: deprecate GNTTABOP_transfer

Hi Juergen,

Quoted 2 lines · Juergen Gross

Add a comment to include/public/grant_table.h that GNTTABOP_transfer is deprecated, in order to discourage new use cases.

From the commit message, it is unclear to me why we are discouraging new use cases and indirectly encouraging current users to move away from the feature.

Patch #1 seems to imply this is because the feature is not present in Linux upstream. But I don't think this is a sufficient reason to deprecate a feature.

A more compelling reason would be that the feature is broken and too complex to fix it.

So can you provide more details?

As a side note, should we also update SUPPORT.md?

Cheers,

Signature · 1 line
Julien Grall
#3 lore raw

Re: [PATCH v2 2/2] xen/include/public: deprecate GNTTABOP_transfer

Quoted 6 lines · Julien Grall

Hi Juergen,

Quoted 2 lines · Juergen Gross

Add a comment to include/public/grant_table.h that GNTTABOP_transfer is deprecated, in order to discourage new use cases.

Quoted 8 lines

From the commit message, it is unclear to me why we are discouraging
new use cases and indirectly encouraging current users to move away from the feature.

Patch #1 seems to imply this is because the feature is not present in Linux upstream. But I don't think this is a sufficient reason to deprecate a feature.

A more compelling reason would be that the feature is broken and too complex to fix it.

So can you provide more details?

It is a feature available for PV domains only, and it is very complex and hasn't been tested for ages.

Quoted 1 line

As a side note, should we also update SUPPORT.md?

Good question.

Juergen

#4 lore raw

Re: [PATCH v2 2/2] xen/include/public: deprecate GNTTABOP_transfer

Quoted 4 lines · Juergen Gross
Quoted 1 line · Julien Grall

As a side note, should we also update SUPPORT.md?

Good question.

I'm not sure here either - talking about individual hypercall sub-ops seems overly small granularity to me for this kind of doc. Plus I don't view deprecation and de-supporting as the same thing. The latter would mean to render unsupported any old XenoLinux which may still be in use, all of the sudden.

What would want gaining an entry in any event imo is CHANGELOG.md.

Jan

#5 lore raw

Re: [PATCH v2 2/2] xen/include/public: deprecate GNTTABOP_transfer

Hi Jan,

Quoted 11 lines · Jan Beulich
Quoted 4 lines · Juergen Gross
Quoted 1 line · Julien Grall

As a side note, should we also update SUPPORT.md?

Good question.

I'm not sure here either - talking about individual hypercall sub-ops seems overly small granularity to me for this kind of doc. Plus I don't view deprecation and de-supporting as the same thing. The latter would mean to render unsupported any old XenoLinux which may still be in use, all of the sudden.

I understand this would result to unsupport some old OSes (not clear how old). However, from what Juergen said this feature is untested.

To me it sound like we are not confident that we could security support this feature.

So I am not sure to understand why we only want to deprecate it.

Cheers,

Signature · 1 line
Julien Grall
#6 lore raw

Re: [PATCH v2 2/2] xen/include/public: deprecate GNTTABOP_transfer

Quoted 13 lines · Julien Grall
Quoted 11 lines · Jan Beulich
Quoted 4 lines · Juergen Gross
Quoted 1 line · Julien Grall

As a side note, should we also update SUPPORT.md?

Good question.

I'm not sure here either - talking about individual hypercall sub-ops seems overly small granularity to me for this kind of doc. Plus I don't view deprecation and de-supporting as the same thing. The latter would mean to render unsupported any old XenoLinux which may still be in use, all of the sudden.

Quoted 7 lines

I understand this would result to unsupport some old OSes (not clear how old). However, from what Juergen said this feature is untested.

To me it sound like we are not confident that we could security support this feature.

So I am not sure to understand why we only want to deprecate it.

Not sure what to say: Rendering unsupported however old guests is not a nice step. Hence my concern (which isn't an outright objection).

Jan

#7 lore raw

Re: [PATCH v2 2/2] xen/include/public: deprecate GNTTABOP_transfer

Hi,

Quoted 17 lines · Jan Beulich
Quoted 16 lines · Julien Grall
Quoted 11 lines · Jan Beulich
Quoted 4 lines · Juergen Gross
Quoted 1 line · Julien Grall

As a side note, should we also update SUPPORT.md?

Good question.

I'm not sure here either - talking about individual hypercall sub-ops seems overly small granularity to me for this kind of doc. Plus I don't view deprecation and de-supporting as the same thing. The latter would mean to render unsupported any old XenoLinux which may still be in use, all of the sudden.

I understand this would result to unsupport some old OSes (not clear how old). However, from what Juergen said this feature is untested.

Quoted 7 lines
Quoted 4 lines

To me it sound like we are not confident that we could security support this feature.

So I am not sure to understand why we only want to deprecate it.

Not sure what to say: Rendering unsupported however old guests is not a nice step. Hence my concern (which isn't an outright objection).

In the past we have removed support for feature we deemed unsafe to use and it would require effort to secure it. This is despite the fact that it may be used in production (e.g. PV devices, qemu trad...).

So I think the question here is really, do you think we can sensibly security support GNTTABOP_transfer?

Cheers,

Signature · 1 line
Julien Grall
#8 lore raw

Re: [PATCH v2 2/2] xen/include/public: deprecate GNTTABOP_transfer

Quoted 26 lines · Julien Grall
Quoted 17 lines · Jan Beulich
Quoted 16 lines · Julien Grall
Quoted 11 lines · Jan Beulich
Quoted 4 lines · Juergen Gross
Quoted 1 line · Julien Grall

As a side note, should we also update SUPPORT.md?

Good question.

I'm not sure here either - talking about individual hypercall sub-ops seems overly small granularity to me for this kind of doc. Plus I don't view deprecation and de-supporting as the same thing. The latter would mean to render unsupported any old XenoLinux which may still be in use, all of the sudden.

I understand this would result to unsupport some old OSes (not clear how old). However, from what Juergen said this feature is untested.

Quoted 7 lines
Quoted 4 lines

To me it sound like we are not confident that we could security support this feature.

So I am not sure to understand why we only want to deprecate it.

Not sure what to say: Rendering unsupported however old guests is not a nice step. Hence my concern (which isn't an outright objection).

Quoted 6 lines

In the past we have removed support for feature we deemed unsafe to use and it would require effort to secure it. This is despite the fact that it may be used in production (e.g. PV devices, qemu trad...).

So I think the question here is really, do you think we can sensibly security support GNTTABOP_transfer?

I don't think it's a question of "can", but of "are we willing to". It would be "can" only if we learned of some seemingly very hard to solve issue. From a workload perspective it would certainly be nice if we didn't have to think about this anymore. Yet like in certain other cases, besides the particular item here I'm also worried of setting a precedent which may then be used to argue for the removal of support for other operations, just to make our lives easier.

Jan

#9 lore raw

Re: [PATCH v2 2/2] xen/include/public: deprecate GNTTABOP_transfer

Quoted 34 lines · Jan Beulich
Quoted 26 lines · Julien Grall
Quoted 17 lines · Jan Beulich
Quoted 16 lines · Julien Grall
Quoted 11 lines · Jan Beulich
Quoted 4 lines · Juergen Gross
Quoted 1 line · Julien Grall

As a side note, should we also update SUPPORT.md?

Good question.

I'm not sure here either - talking about individual hypercall sub-ops seems overly small granularity to me for this kind of doc. Plus I don't view deprecation and de-supporting as the same thing. The latter would mean to render unsupported any old XenoLinux which may still be in use, all of the sudden.

I understand this would result to unsupport some old OSes (not clear how old). However, from what Juergen said this feature is untested.

Quoted 7 lines
Quoted 4 lines

To me it sound like we are not confident that we could security support this feature.

So I am not sure to understand why we only want to deprecate it.

Not sure what to say: Rendering unsupported however old guests is not a nice step. Hence my concern (which isn't an outright objection).

Quoted 6 lines

In the past we have removed support for feature we deemed unsafe to use and it would require effort to secure it. This is despite the fact that it may be used in production (e.g. PV devices, qemu trad...).

So I think the question here is really, do you think we can sensibly security support GNTTABOP_transfer?

Quoted 7 lines

I don't think it's a question of "can", but of "are we willing to". It would be "can" only if we learned of some seemingly very hard to solve issue. From a workload perspective it would certainly be nice if we didn't have to think about this anymore. Yet like in certain other cases, besides the particular item here I'm also worried of setting a precedent which may then be used to argue for the removal of support for other operations, just to make our lives easier.

Just one comment: desupporting GNTTABOP_transfer would hit only systems with a XenoLinux dom0. I think those running on a still supported Xen version are really rare these days.

Juergen

#10 lore raw

Re: [PATCH v2 2/2] xen/include/public: deprecate GNTTABOP_transfer

In reply to Juergen Gross

Hi,

Quoted 9 lines · Juergen Gross
Quoted 8 lines · Julien Grall

Hi Juergen,

Quoted 2 lines · Juergen Gross

Add a comment to include/public/grant_table.h that GNTTABOP_transfer is deprecated, in order to discourage new use cases.

 From the commit message, it is unclear to me why we are discouraging new use cases and indirectly encouraging current users to move away from the feature.

Quoted 8 lines
Quoted 5 lines

Patch #1 seems to imply this is because the feature is not present in Linux upstream. But I don't think this is a sufficient reason to deprecate a feature.

A more compelling reason would be that the feature is broken and too complex to fix it.

So can you provide more details?

It is a feature available for PV domains only, and it is very complex and hasn't been tested for ages.

Right. To reply to Jan's e-mail here, shouldn't we also de-support (either completely or security) in this case?

My concern here is you wrote this code has been untested for ages (not clear how long) and complex. So potentially this means there are security issues in it.

Cheers,

Signature · 1 line
Julien Grall
#11 lore raw

Re: [PATCH v2 2/2] xen/include/public: deprecate GNTTABOP_transfer

Quoted 16 lines · Julien Grall

Hi,

Quoted 13 lines · Juergen Gross
Quoted 12 lines · Julien Grall

Hi Juergen,

Quoted 2 lines · Juergen Gross

Add a comment to include/public/grant_table.h that GNTTABOP_transfer is deprecated, in order to discourage new use cases.

 From the commit message, it is unclear to me why we are discouraging new use cases and indirectly encouraging current users to move away from the feature.

Patch #1 seems to imply this is because the feature is not present in Linux upstream. But I don't think this is a sufficient reason to deprecate a feature.

A more compelling reason would be that the feature is broken and too complex to fix it.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

So can you provide more details?

It is a feature available for PV domains only, and it is very complex and hasn't been tested for ages.

Right. To reply to Jan's e-mail here, shouldn't we also de-support (either completely or security) in this case?

My concern here is you wrote this code has been untested for ages (not clear how long) and complex. So potentially this means there are security issues in it.

In case we are doing this, we should set the default to disable the transfer functionality.

Juergen