]> xenbits.xensource.com Git - xen.git/commitdiff
tools/xenstore: call remove_domid_from_perm() for special nodes
authorJuergen Gross <jgross@suse.com>
Wed, 9 Nov 2022 10:01:56 +0000 (11:01 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 9 Nov 2022 10:01:56 +0000 (11:01 +0100)
When destroying a domain, any stale permissions of the domain must be
removed from the special nodes "@...", too. This was not done in the
fix for XSA-322.

Fixes: 496306324d8d ("tools/xenstore: revoke access rights for removed domains")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
master commit: 0751a75e3996cf6efd3925a90b4776660d8df2bc
master date: 2022-11-02 12:08:22 +0100

tools/xenstore/xenstored_domain.c

index ee4b19387db8bc3d8219c92c4931e75286db13b4..8cc36ee44c54b31e36a4929ee7fe6be90f509487 100644 (file)
@@ -196,6 +196,27 @@ static void unmap_interface(void *interface)
        xengnttab_unmap(*xgt_handle, interface, 1);
 }
 
+static void remove_domid_from_perm(struct node_perms *perms,
+                                  struct domain *domain)
+{
+       unsigned int cur, new;
+
+       if (perms->p[0].id == domain->domid)
+               perms->p[0].id = priv_domid;
+
+       for (cur = new = 1; cur < perms->num; cur++) {
+               if (perms->p[cur].id == domain->domid)
+                       continue;
+
+               if (new != cur)
+                       perms->p[new] = perms->p[cur];
+
+               new++;
+       }
+
+       perms->num = new;
+}
+
 static int domain_tree_remove_sub(const void *ctx, struct connection *conn,
                                  struct node *node, void *arg)
 {
@@ -246,6 +267,9 @@ static void domain_tree_remove(struct domain *domain)
                        syslog(LOG_ERR,
                               "error when looking for orphaned nodes\n");
        }
+
+       remove_domid_from_perm(&dom_release_perms, domain);
+       remove_domid_from_perm(&dom_introduce_perms, domain);
 }
 
 static int destroy_domain(void *_domain)