[PATCH] tools/xenstore: don't let special watches be children of /

Juergen Gross posted 1 patch 2 years ago
Test gitlab-ci failed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20220427135156.4605-1-jgross@suse.com
There is a newer version of this series
tools/xenstore/xenstored_domain.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] tools/xenstore: don't let special watches be children of /
Posted by Juergen Gross 2 years ago
When firing special watches (e.g. "@releaseDomain"), they will be
regarded to be valid children of the "/" node. So a domain having
registered a watch for "/" and having the privilege to receive
the special watches will receive those special watch events for the
registered "/" watch.

Fix that by calling the related fire_watches() with the "exact"
parameter set to true, causing a mismatch for the "/" node.

Reported-by: Raphael Ning <raphning@gmail.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/xenstore/xenstored_domain.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index ae065fcbee..80ba1d627b 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -231,7 +231,7 @@ static int destroy_domain(void *_domain)
 			unmap_interface(domain->interface);
 	}
 
-	fire_watches(NULL, domain, "@releaseDomain", NULL, false, NULL);
+	fire_watches(NULL, domain, "@releaseDomain", NULL, true, NULL);
 
 	wrl_domain_destroy(domain);
 
@@ -282,7 +282,7 @@ void check_domains(void)
 	}
 
 	if (notify)
-		fire_watches(NULL, NULL, "@releaseDomain", NULL, false, NULL);
+		fire_watches(NULL, NULL, "@releaseDomain", NULL, true, NULL);
 }
 
 /* We scan all domains rather than use the information given here. */
@@ -495,7 +495,7 @@ static struct domain *introduce_domain(const void *ctx,
 
 		if (!is_master_domain && !restore)
 			fire_watches(NULL, ctx, "@introduceDomain", NULL,
-				     false, NULL);
+				     true, NULL);
 	} else {
 		/* Use XS_INTRODUCE for recreating the xenbus event-channel. */
 		if (domain->port)
-- 
2.34.1
Re: [PATCH] tools/xenstore: don't let special watches be children of /
Posted by Raphael Ning 2 years ago
Hi Juergen,


On 27/04/2022 14:51, Juergen Gross wrote:
> When firing special watches (e.g. "@releaseDomain"), they will be
> regarded to be valid children of the "/" node. So a domain having
> registered a watch for "/" and having the privilege to receive
> the special watches will receive those special watch events for the
> registered "/" watch.
>
> Fix that by calling the related fire_watches() with the "exact"
> parameter set to true, causing a mismatch for the "/" node.
>
> Reported-by: Raphael Ning <raphning@gmail.com>


Can I ask you to use my Amazon email instead:

Reported-by: Raphael Ning <raphning@amazon.com>

Sorry about the inconsistency. I work on Xen as part of my job, but I decided to use Gmail for posting on xen-devel, because I heard that it's a pain to make Amazon mail work properly with external mailing lists.


> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
>  tools/xenstore/xenstored_domain.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
> index ae065fcbee..80ba1d627b 100644
> --- a/tools/xenstore/xenstored_domain.c
> +++ b/tools/xenstore/xenstored_domain.c
> @@ -231,7 +231,7 @@ static int destroy_domain(void *_domain)
>  			unmap_interface(domain->interface);
>  	}
>  
> -	fire_watches(NULL, domain, "@releaseDomain", NULL, false, NULL);
> +	fire_watches(NULL, domain, "@releaseDomain", NULL, true, NULL);
>  
>  	wrl_domain_destroy(domain);
>  
> @@ -282,7 +282,7 @@ void check_domains(void)
>  	}
>  
>  	if (notify)
> -		fire_watches(NULL, NULL, "@releaseDomain", NULL, false, NULL);
> +		fire_watches(NULL, NULL, "@releaseDomain", NULL, true, NULL);
>  }
>  
>  /* We scan all domains rather than use the information given here. */
> @@ -495,7 +495,7 @@ static struct domain *introduce_domain(const void *ctx,
>  
>  		if (!is_master_domain && !restore)
>  			fire_watches(NULL, ctx, "@introduceDomain", NULL,
> -				     false, NULL);
> +				     true, NULL);
>  	} else {
>  		/* Use XS_INTRODUCE for recreating the xenbus event-channel. */
>  		if (domain->port)


Thanks, the patch looks good.

Reviewed-by: Raphael Ning <raphning@amazon.com>


Raphael
Re: [PATCH] tools/xenstore: don't let special watches be children of /
Posted by Juergen Gross 2 years ago
On 27.04.22 16:25, Raphael Ning wrote:
> Hi Juergen,
> 
> 
> On 27/04/2022 14:51, Juergen Gross wrote:
>> When firing special watches (e.g. "@releaseDomain"), they will be
>> regarded to be valid children of the "/" node. So a domain having
>> registered a watch for "/" and having the privilege to receive
>> the special watches will receive those special watch events for the
>> registered "/" watch.
>>
>> Fix that by calling the related fire_watches() with the "exact"
>> parameter set to true, causing a mismatch for the "/" node.
>>
>> Reported-by: Raphael Ning <raphning@gmail.com>
> 
> 
> Can I ask you to use my Amazon email instead:
> 
> Reported-by: Raphael Ning <raphning@amazon.com>

Yes, of course.

> 
> Sorry about the inconsistency. I work on Xen as part of my job, but I decided to use Gmail for posting on xen-devel, because I heard that it's a pain to make Amazon mail work properly with external mailing lists.
> 
> 
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>>   tools/xenstore/xenstored_domain.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
>> index ae065fcbee..80ba1d627b 100644
>> --- a/tools/xenstore/xenstored_domain.c
>> +++ b/tools/xenstore/xenstored_domain.c
>> @@ -231,7 +231,7 @@ static int destroy_domain(void *_domain)
>>   			unmap_interface(domain->interface);
>>   	}
>>   
>> -	fire_watches(NULL, domain, "@releaseDomain", NULL, false, NULL);
>> +	fire_watches(NULL, domain, "@releaseDomain", NULL, true, NULL);
>>   
>>   	wrl_domain_destroy(domain);
>>   
>> @@ -282,7 +282,7 @@ void check_domains(void)
>>   	}
>>   
>>   	if (notify)
>> -		fire_watches(NULL, NULL, "@releaseDomain", NULL, false, NULL);
>> +		fire_watches(NULL, NULL, "@releaseDomain", NULL, true, NULL);
>>   }
>>   
>>   /* We scan all domains rather than use the information given here. */
>> @@ -495,7 +495,7 @@ static struct domain *introduce_domain(const void *ctx,
>>   
>>   		if (!is_master_domain && !restore)
>>   			fire_watches(NULL, ctx, "@introduceDomain", NULL,
>> -				     false, NULL);
>> +				     true, NULL);
>>   	} else {
>>   		/* Use XS_INTRODUCE for recreating the xenbus event-channel. */
>>   		if (domain->port)
> 
> 
> Thanks, the patch looks good.
> 
> Reviewed-by: Raphael Ning <raphning@amazon.com>

Thanks,


Juergen