[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [BUG v2] common/domctl: xsm update for get_domain_state access
- To: Jürgen Groß <jgross@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
- From: Jason Andryuk <jason.andryuk@xxxxxxx>
- Date: Thu, 19 Feb 2026 06:31:05 -0500
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=qYK2ZDaHL3CDGHtV+ngCMUktxVage+/6HNdZScp0ESE=; b=QjsL2hJgCxJvFCYSrGfinf5c7IZ8ZryrZFpDtmechZat9wGQI4h2Sb0RGXRDuf65M5M6vtn16LQx2QO+/GYrQFV19c0+9CyGBIoZRjqKHZCqqh0nyUK4Z+pmqeorwpC+t9V9DiLamEEoEoAroNbxazuEvOTSHh8dbo1NRX4SN8QtOmxV/BRNzanM+NkjJOidVwwe2LqJmlncOhwXAUTUZ0T7I2FVnl5r3BH6SJcJkjrKEnGdMx0n5/g+TBWGLUCnmNbCvhZyHxXYA+CG2O36r5zU8Ko0pXJIAeg0r7CjFdfz+agM24rvv1fk/70Ct1ITANDImSP5c77Sc3tVBqaVEg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZrUgK1yEFZqyDuZJXPZ+qkG5TC8AzaFpggcSH/6HY7oIc9s6V2e8G2GPM/OuTP52BDlt+yk4IS3aePfLknJ+2bGBKZwcIfB+gWFXmV/2ek1Jn6f/JBKIqZJGFm3RCM4OSrUf4ih+KdiOH1Z4F9s35bt0aZ7m/jPXYaGoxGnQ0RdHB74uwn/dy4+blC9t1eMkOe9AkQgH6CTGbdwsq9oMcGiopzxhX+E+7aIwpLjB2ydKZp26gy+DYC9VMVBSHMWroqxL5e4PMSpdKJ0ieiC/JSpU5Tx/2MgoIUb/+WNdW2Bva3dwU7S9gvjgw6EmVcG2qCxnVQsJbiSXrF9i/bnpkA==
- Cc: Chris Rogers <rogersc@xxxxxxxxxxxx>, Dmytro Firsov <dmytro_firsov@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "Anthony PERARD" <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Thu, 19 Feb 2026 14:37:23 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 2026-02-19 06:21, Jürgen Groß wrote:
On 19.02.26 12:13, Jan Beulich wrote:
On 19.02.2026 12:03, Juergen Gross wrote:
On 19.02.26 11:52, Jan Beulich wrote:
On 19.02.2026 00:04, Jason Andryuk wrote:
On 2026-02-18 14:08, Daniel P. Smith wrote:
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -210,7 +210,7 @@ static void set_domain_state_info(struct
xen_domctl_get_domain_state *info,
int get_domain_state(struct xen_domctl_get_domain_state *info,
struct domain *d,
domid_t *domid)
{
- unsigned int dom;
+ unsigned int dom = -1;
int rc = -ENOENT;
struct domain *hdl;
@@ -219,6 +219,10 @@ int get_domain_state(struct
xen_domctl_get_domain_state *info, struct domain *d,
if ( d )
{
+ rc = xsm_get_domain_state(XSM_XS_PRIV, d);
+ if ( rc )
+ return rc;
+
set_domain_state_info(info, d);
return 0;
@@ -238,28 +242,39 @@ int get_domain_state(struct
xen_domctl_get_domain_state *info, struct domain *d,
Between the two hunks is this:
hdl = lock_dom_exc_handler();
/*
* Only domain registered for VIRQ_DOM_EXC event is allowed
to query
* domains having changed state.
*/
if ( current->domain != hdl )
{
rc = -EACCES;
goto out;
}
So it is only the domain with VIRQ_DOM_EXC that can enter the while
loop:
while ( dom_state_changed )
{
- dom = find_first_bit(dom_state_changed, DOMID_MASK + 1);
+ dom = find_next_bit(dom_state_changed, DOMID_MASK + 1,
dom + 1);
if ( dom >= DOMID_FIRST_RESERVED )
break;
+
+ d = rcu_lock_domain_by_id(dom);
+ if ( d && xsm_get_domain_state(XSM_XS_PRIV, d) )
... if the VIRQ_DOM_EXC owner is denied for domain d ...
+ {
+ rcu_unlock_domain(d);
+ d = NULL;
+ continue;
... the caller would continue ...
+ }
+
if ( test_and_clear_bit(dom, dom_state_changed) )
... and this bit would never be cleared. Should the VIRQ_DOM_EXC
owner
always get to clear the bit even if it cannot see the result?
I don't think so, no. Whenever a legitimate consumer occurs (the
owner of
VIRQ_DOM_EXC can change, after all), it'll then consume the bits as
needed.
More generally, I think we're better off not making the code here
depend
too much on that special VIRQ_DOM_EXC property.
OTOH a new VIRQ_DOM_EXC owner will result in a complete reset of the
bitmap
anyway (that is: the bits for all existing domains will be set, while
all
others will be cleared).
Yes, while writing my reply I wondered whether I should mention that.
To keep
things a little more simple, I didn't. Plus for this aspect the last
sentence
of my earlier reply also applies.
I believe flask settings can be changed, right?
If so, clearing the bit would be affecting the scenario where the
VIRQ_DOM_EXC
is NOT changed, but the flask settings are updated to allow it obtaining
info
about d.
Yes, this could happen, so the bits should remain set.
Thanks,
Jason
|