aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenstore/xenstored_domain.c
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2006-11-13 10:43:29 +0000
committerEwan Mellor <ewan@xensource.com>2006-11-13 10:43:29 +0000
commitdb34d2aaa5f5eb5826a939fe8eacb91432a87d42 (patch)
tree3ca8ca28a68e078e67ac2c9e39b539b0fb06a99c /tools/xenstore/xenstored_domain.c
parentede7828af2f265d3a40abe8905611861c0f88867 (diff)
downloadxen-db34d2aaa5f5eb5826a939fe8eacb91432a87d42.tar.gz
xen-db34d2aaa5f5eb5826a939fe8eacb91432a87d42.tar.bz2
xen-db34d2aaa5f5eb5826a939fe8eacb91432a87d42.zip
Fix handling of the entries-per-domain quota. Entries which are created by
the guest but deleted by dom0 were remaining accounted against the guest, which meant that the guest would eventually run out of quota. This patch also prevents unprivileged domains from changing the owner of a node. One guest could attack another by creating nodes and then transferring them to the ownership of another, and though the accounting could be made to work properly in this case, domains should never be transferring nodes in any case, so it seems safer just to disallow the operation entirely. Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools/xenstore/xenstored_domain.c')
-rw-r--r--tools/xenstore/xenstored_domain.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index 40cc20386a..d21ae7b9c7 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -501,18 +501,35 @@ int domain_init(void)
return xce_handle;
}
-void domain_entry_inc(struct connection *conn)
+void domain_entry_inc(struct connection *conn, struct node *node)
{
- if (!conn || !conn->domain)
+ struct domain *d;
+
+ if (!conn)
return;
- conn->domain->nbentry++;
+
+ if (node->perms && node->perms[0].id != conn->id) {
+ d = find_domain_by_domid(node->perms[0].id);
+ if (d)
+ d->nbentry++;
+ }
+ else if (conn->domain) {
+ conn->domain->nbentry++;
+ }
}
-void domain_entry_dec(struct connection *conn)
+void domain_entry_dec(struct connection *conn, struct node *node)
{
- if (!conn || !conn->domain)
+ struct domain *d;
+
+ if (!conn)
return;
- if (conn->domain->nbentry)
+
+ if (node->perms && node->perms[0].id != conn->id) {
+ d = find_domain_by_domid(node->perms[0].id);
+ if (d && d->nbentry)
+ d->nbentry--;
+ } else if (conn->domain && conn->domain->nbentry)
conn->domain->nbentry--;
}