domctl: handle XEN_DOMCTL_ioport_mapping without acquiring domctl lock

With dedicated locking added, the domctl lock isn't required here anymore.
As the handling is in arch-specific code (x86 only), almost no code is
being moved, but a 2nd (extensible to other sub-ops) invocation of
arch_do_domctl() is being added. Move just the re-purposed dedicated XSM
check as early as possible.

In flask_domctl() don't put #ifdef around the moved case label.

This is part of XSA-492.

Fixes: fda49f9b3f ("Add build option to allow more hypercalls from stubdoms")
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com>
(cherry picked from commit 9ac94138a5)
This commit is contained in:
Jan Beulich authored and Andrew Cooper committed 2026-06-04 22:29:12 +01:00
1 parent 95bfcd4084
commit e4a65bd423
4 files changed
+13 -6

No files matched your search

+6 -3
View File
@@ -619,12 +619,15 @@ long arch_do_domctl(
break;
}
ret = xsm_ioport_mapping(XSM_DM_PRIV, d, fmp, fmp + np - 1, add);
if ( ret )
break;
hvm = &d->arch.hvm;
iocaps_double_lock(d, true);
if ( !ioports_access_permitted(currd, fmp, fmp + np - 1) ||
(ret = xsm_ioport_mapping(XSM_HOOK, d, fmp, fmp + np - 1, add)) )
ret = ret ?: -EPERM;
if ( !ioports_access_permitted(currd, fmp, fmp + np - 1) )
ret = -EPERM;
else if ( add )
{
printk(XENLOG_G_INFO
+4
View File
@@ -452,6 +452,10 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
goto domctl_out_unlock_domonly;
}
case XEN_DOMCTL_ioport_mapping:
ret = arch_do_domctl(op, d, u_domctl);
goto domctl_out_unlock_domonly;
default:
/* Everything else handled further down. */
break;
+2 -2
View File
@@ -167,12 +167,12 @@ static XSM_INLINE int cf_check xsm_domctl(
XSM_ASSERT_ACTION(XSM_OTHER);
switch ( cmd )
{
case XEN_DOMCTL_ioport_mapping:
case XEN_DOMCTL_bind_pt_irq:
case XEN_DOMCTL_unbind_pt_irq:
return xsm_default_action(XSM_DM_PRIV, current->domain, d);
case XEN_DOMCTL_getdomaininfo:
case XEN_DOMCTL_ioport_mapping:
case XEN_DOMCTL_memory_mapping:
ASSERT_UNREACHABLE();
return -EILSEQ;
@@ -764,7 +764,7 @@ static XSM_INLINE int cf_check xsm_ioport_permission(
static XSM_INLINE int cf_check xsm_ioport_mapping(
XSM_DEFAULT_ARG struct domain *d, uint32_t s, uint32_t e, uint8_t allow)
{
XSM_ASSERT_ACTION(XSM_HOOK);
XSM_ASSERT_ACTION(XSM_DM_PRIV);
return xsm_default_action(action, current->domain, d);
}
+1 -1
View File
@@ -680,6 +680,7 @@ static int cf_check flask_domctl(struct domain *d, unsigned int cmd,
/* These have individual XSM hooks and don't make it here. */
case XEN_DOMCTL_getdomaininfo:
case XEN_DOMCTL_ioport_mapping:
case XEN_DOMCTL_memory_mapping:
ASSERT_UNREACHABLE();
return -EILSEQ;
@@ -698,7 +699,6 @@ static int cf_check flask_domctl(struct domain *d, unsigned int cmd,
/* These have individual XSM hooks (arch/x86/domctl.c) */
case XEN_DOMCTL_shadow_op:
case XEN_DOMCTL_ioport_permission:
case XEN_DOMCTL_ioport_mapping:
#endif
#ifdef CONFIG_HAS_PASSTHROUGH
/*
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.