|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 for-4.22? 4/7] domctl: restrict permission check for XEN_DOMCTL_memory_mapping's remove form
While the granting of permissions when mapping was already removed from
this operation, check whether permissions actually were granted when
adding a mapping; the check of the requester having permission remains
unaltered.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: Avoid double evaluation of "add". Re-do description, to avoid
mentioning behavior introduced only by a subsequent patch.
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -436,25 +436,16 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe
goto domctl_out_unlock_rcuonly;
#endif
+ /*
+ * NB: The double lock isn't really needed when !add, but is used
anyway
+ * to keep things simple.
+ */
iocaps_double_lock(d, false);
ret = -EPERM;
- if ( !iomem_access_permitted(current->domain, mfn, mfn_end) ||
- !iomem_access_permitted(d, mfn, mfn_end) )
+ if ( !iomem_access_permitted(current->domain, mfn, mfn_end) )
/* Nothing. */;
- else if ( add )
- {
- printk(XENLOG_G_DEBUG
- "memory_map:add: %pd gfn=%lx mfn=%lx nr=%lx\n",
- d, gfn, mfn, nr_mfns);
-
- ret = map_mmio_regions(d, _gfn(gfn), nr_mfns, _mfn(mfn));
- if ( ret < 0 )
- printk(XENLOG_G_WARNING
- "memory_map:fail: %pd gfn=%lx mfn=%lx nr=%lx ret:%ld\n",
- d, gfn, mfn, nr_mfns, ret);
- }
- else
+ else if ( !add )
{
printk(XENLOG_G_DEBUG
"memory_map:remove: %pd gfn=%lx mfn=%lx nr=%lx\n",
@@ -466,6 +457,18 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe
"memory_map: error %ld removing %pd access to
[%lx,%lx]\n",
ret, d, mfn, mfn_end);
}
+ else if ( iomem_access_permitted(d, mfn, mfn_end) )
+ {
+ printk(XENLOG_G_DEBUG
+ "memory_map:add: %pd gfn=%lx mfn=%lx nr=%lx\n",
+ d, gfn, mfn, nr_mfns);
+
+ ret = map_mmio_regions(d, _gfn(gfn), nr_mfns, _mfn(mfn));
+ if ( ret < 0 )
+ printk(XENLOG_G_WARNING
+ "memory_map:fail: %pd gfn=%lx mfn=%lx nr=%lx ret:%ld\n",
+ d, gfn, mfn, nr_mfns, ret);
+ }
iocaps_double_unlock(d, false);
goto domctl_out_unlock_rcuonly;
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |