From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>, Julien Grall <julien@xen.org>,
Anthony PERARD <anthony.perard@vates.tech>,
Jason Andryuk <jason.andryuk@amd.com>
Subject: [PATCH v2 4/4] tools/xenstored: remove permissions related to dead domain
Date: Wed, 29 Apr 2026 14:06:19 +0200 [thread overview]
Message-ID: <20260429120619.1013440-5-jgross@suse.com> (raw)
In-Reply-To: <20260429120619.1013440-1-jgross@suse.com>
Wit unprivileged domains now capable to use the @releaseDomain watch,
there is no reason not to remove any node permissions which relate to
a domain which has been removed.
This resolves a complex scenario where a new domain could inherit the
permissions of an old one with the same domid.
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
---
V2: use priv_domid instead of literal 0 in message (Jason Andryuk)
---
tools/xenstored/domain.c | 62 ++++++++++++++++++++++++----------------
1 file changed, 37 insertions(+), 25 deletions(-)
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 7074abd197..2db452144d 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -569,24 +569,10 @@ static int domain_tree_remove_sub(const void *ctx, struct connection *conn,
struct node *node, void *arg)
{
struct domain *domain = arg;
- int ret = WALK_TREE_OK;
-
- if (node->perms[0].id != domain->domid)
- return WALK_TREE_OK;
+ bool node_changed = false;
+ unsigned int i;
- if (keep_orphans) {
- domain_nbentry_dec(NULL, domain->domid);
- node->perms[0].id = priv_domid;
- node->acc.memory = 0;
- domain_nbentry_inc(NULL, priv_domid);
- if (write_node_raw(NULL, node->name, node, NODE_MODIFY, true)) {
- /* That's unfortunate. We only can try to continue. */
- syslog(LOG_ERR,
- "error when moving orphaned node %s to dom0\n",
- node->name);
- } else
- trace("orphaned node %s moved to dom0\n", node->name);
- } else {
+ if (node->perms[0].id == domain->domid && !keep_orphans) {
if (rm_node(NULL, ctx, node->name)) {
/* That's unfortunate. We only can try to continue. */
syslog(LOG_ERR,
@@ -596,10 +582,39 @@ static int domain_tree_remove_sub(const void *ctx, struct connection *conn,
trace("orphaned node %s deleted\n", node->name);
/* Skip children in all cases in order to avoid more errors. */
- ret = WALK_TREE_SKIP_CHILDREN;
+ return WALK_TREE_SKIP_CHILDREN;
}
- return domain->acc_val[ACC_NODES] ? ret : WALK_TREE_SUCCESS_STOP;
+ if (node->perms[0].id == domain->domid) {
+ domain_nbentry_dec(NULL, domain->domid);
+ node->perms[0].id = priv_domid;
+ node->acc.memory = 0;
+ domain_nbentry_inc(NULL, priv_domid);
+ trace("moving orphaned node %s to dom%d\n", node->name,
+ priv_domid);
+ node_changed = true;
+ }
+
+ for (i = 1; i < node->hdr.num_perms; i++) {
+ if (node->perms[i].id != domain->domid)
+ continue;
+ memmove(node->perms + i, node->perms + i + 1,
+ sizeof(*node->perms) * (node->hdr.num_perms - i - 1));
+ node->hdr.num_perms--;
+ i--;
+ node_changed = true;
+ }
+
+ if (node_changed) {
+ if (write_node_raw(NULL, node->name, node, NODE_MODIFY, true)) {
+ /* That's unfortunate. We only can try to continue. */
+ syslog(LOG_ERR,
+ "error when writing modified node %s\n",
+ node->name);
+ }
+ }
+
+ return WALK_TREE_OK;
}
static void domain_tree_remove(struct domain *domain)
@@ -607,12 +622,9 @@ static void domain_tree_remove(struct domain *domain)
int ret;
struct walk_funcs walkfuncs = { .enter = domain_tree_remove_sub };
- if (domain->acc_val[ACC_NODES]) {
- ret = walk_node_tree(domain, NULL, "/", &walkfuncs, domain);
- if (ret == WALK_TREE_ERROR_STOP)
- syslog(LOG_ERR,
- "error when looking for orphaned nodes\n");
- }
+ ret = walk_node_tree(domain, NULL, "/", &walkfuncs, domain);
+ if (ret == WALK_TREE_ERROR_STOP)
+ syslog(LOG_ERR, "error when looking for orphaned nodes\n");
walk_node_tree(domain, NULL, "@releaseDomain", &walkfuncs, domain);
walk_node_tree(domain, NULL, "@introduceDomain", &walkfuncs, domain);
--
2.53.0
next prev parent reply other threads:[~2026-04-29 12:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 12:06 [PATCH v2 0/4] tools/xenstore: fix issue related to XSA-417 Juergen Gross
2026-04-29 12:06 ` [PATCH v2 1/4] xen/public: introduce DOMID_ANY Juergen Gross
2026-05-14 1:15 ` Stefano Stabellini
2026-04-29 12:06 ` [PATCH v2 2/4] tools/xenstored: add support for "all domains" node permission Juergen Gross
2026-04-29 12:06 ` [PATCH v2 3/4] tools/xenstored: allow @releaseDomain watch for all domains Juergen Gross
2026-04-29 12:06 ` Juergen Gross [this message]
2026-04-29 16:41 ` [PATCH v2 4/4] tools/xenstored: remove permissions related to dead domain Jason Andryuk
2026-05-07 7:43 ` Jürgen Groß
2026-05-07 7:53 ` Jan Beulich
2026-05-12 15:48 ` [PATCH v2 0/4] tools/xenstore: fix issue related to XSA-417 Oleksii Kurochko
2026-05-12 15:52 ` Jürgen Groß
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260429120619.1013440-5-jgross@suse.com \
--to=jgross@suse.com \
--cc=anthony.perard@vates.tech \
--cc=jason.andryuk@amd.com \
--cc=julien@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.