RFC XSM/evtchn: Never pretend to have successfully created a Xen event channel
PATCH 1/1 RFC XSM/evtchn: Never pretend to have successfully created a Xen event channel
This is RFC because explicitly changes the logic introduced by c/s b34f2c375 "xsm: label xen-consumer event channels", and is only compile tested.
Xen event channels are not internal resources. They still have one end in a domain, and are created at the request of privileged domains. This logic which "successfully" creates a Xen event channel opens up undesirable failure cases with ill-specified XSM policies.
If a domain is permitted to create ioreq servers or memevent listeners, but not to create event channels, the ioreq/memevent creation will succeed but attempting to bind the returned event channel will fail without any indication of a permission error.
--- xen/common/event_channel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
xen/common/event_channel.c +3 -1
@@ -1160,11 +1160,13 @@ int alloc_unbound_xen_event_channel( chn =evtchn_from_port (d, port); rc =xsm_evtchn_unbound (XSM_TARGET , d, chn, remote_domid); +if ( rc ) + goto out; chn->state =ECS_UNBOUND ; chn->xen_consumer =get_xen_consumer (notification_fn); chn->notify_vcpu_id = local_vcpu->vcpu_id; - chn->u.unbound.remote_domid = !rc ? remote_domid :DOMID_INVALID ; + chn->u.unbound.remote_domid = remote_domid; out:spin_unlock (&d->event_lock);
Signature · 1 line
1.7.10.4
Quoted 29 lines · Andrew Cooper
This is RFC because explicitly changes the logic introduced by c/s
b34f2c375"xsm: label xen-consumer event channels", and is only compile tested.Xen event channels are not internal resources. They still have one end in a domain, and are created at the request of privileged domains. This logic which "successfully" creates a Xen event channel opens up undesirable failure cases with ill-specified XSM policies.
If a domain is permitted to create ioreq servers or memevent listeners, but not to create event channels, the ioreq/memevent creation will succeed but attempting to bind the returned event channel will fail without any indication of a permission error.
Signed-off-by Andrew Cooper <[email protected]>CC Daniel De Graaf <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Tim Deegan <[email protected]>CC Ian Campbell <[email protected]>CC Ian Jackson <[email protected]>--- xen/common/event_channel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)xen/common/event_channel.c +0
-0
xen/common/event_channel.c int alloc_unbound_xen_event_channel( · line 1164
Quoted 5 lines
xen/common/event_channel.c +2
-0@@ -1160,11 +1160,13 @@ int alloc_unbound_xen_event_channel( chn =evtchn_from_port (d, port); rc =xsm_evtchn_unbound (XSM_TARGET , d, chn, remote_domid); +if ( rc ) + goto out;
out here appears to return port, not rc so you aren't returning failure, but an even more half setup port than before.
And I think you need to free the port on failure too.
Quoted 9 lines
xen/common/event_channel.c +1
-1chn->state =ECS_UNBOUND ; chn->xen_consumer =get_xen_consumer (notification_fn); chn->notify_vcpu_id = local_vcpu->vcpu_id; - chn->u.unbound.remote_domid = !rc ? remote_domid :DOMID_INVALID ; + chn->u.unbound.remote_domid = remote_domid; out:spin_unlock (&d->event_lock);
Quoted 32 lines · Ian Campbell
Quoted 31 lines · Andrew Cooper
This is RFC because explicitly changes the logic introduced by c/s
b34f2c375"xsm: label xen-consumer event channels", and is only compile tested.Xen event channels are not internal resources. They still have one end in a domain, and are created at the request of privileged domains. This logic which "successfully" creates a Xen event channel opens up undesirable failure cases with ill-specified XSM policies.
If a domain is permitted to create ioreq servers or memevent listeners, but not to create event channels, the ioreq/memevent creation will succeed but attempting to bind the returned event channel will fail without any indication of a permission error.
Signed-off-by Andrew Cooper <[email protected]>CC Daniel De Graaf <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Tim Deegan <[email protected]>CC Ian Campbell <[email protected]>CC Ian Jackson <[email protected]>--- xen/common/event_channel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)xen/common/event_channel.c +0
-0@@ -1160,11 +1160,13 @@ int alloc_unbound_xen_event_channel( chn =evtchn_from_port (d, port);
Quoted 5 lines
xen/common/event_channel.c int alloc_unbound_xen_event_channel( · line 1164
Quoted 3 lines
xen/common/event_channel.c +2
-0rc =xsm_evtchn_unbound (XSM_TARGET , d, chn, remote_domid); +if ( rc ) + goto out;out here appears to return port, not rc so you aren't returning failure, but an even more half setup port than before.
Ah yes - so I am. rc was intended. All callers do correctly check for < 0 to indicate failure.
Quoted 2 lines
And I think you need to free the port on failure too.
At the point that we bail, chn->state is still ECS_FREE so there is nothing to deallocate.
~Andrew
Quoted 11 lines
Quoted 10 lines
xen/common/event_channel.c +1
-1chn->state =ECS_UNBOUND ; chn->xen_consumer =get_xen_consumer (notification_fn); chn->notify_vcpu_id = local_vcpu->vcpu_id; - chn->u.unbound.remote_domid = !rc ? remote_domid :DOMID_INVALID ; + chn->u.unbound.remote_domid = remote_domid; out:spin_unlock (&d->event_lock);
Quoted 8 lines · Andrew Cooper
This is RFC because explicitly changes the logic introduced by c/s
b34f2c375"xsm: label xen-consumer event channels", and is only compile tested.Xen event channels are not internal resources. They still have one end in a domain, and are created at the request of privileged domains. This logic which "successfully" creates a Xen event channel opens up undesirable failure cases with ill-specified XSM policies.
Quoted 6 lines
If a domain is permitted to create ioreq servers or memevent listeners, but not to create event channels, the ioreq/memevent creation will succeed but attempting to bind the returned event channel will fail without any indication of a permission error.
Signed-off-by Andrew Cooper <[email protected]>
This feature was originally required in order to support HVM domains which are created by a (non-dom0) toolstack domain which does not itself provide any services to the HVM domain. During creation, the domain would create the ioreq event channels to the toolstack, which was not permitted by the XSM policy; masking this error allowed the channels to be created and then replaced (correctly) when the device model domain was set.
From my current inspection, this workaround may no longer be needed. In any case, I think it is better to expose the error and force the caller to explicitly request a dummy event channel (or just postpone creation).
Signature · 2 lines
Daniel De Graaf National Security Agency