summaryrefslogtreecommitdiff
blob: dd7f382a23c17dee14902b427258ff3b393dc5f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From 3e51699fcc578c7c005fd4add70cf7c8117d0af9 Mon Sep 17 00:00:00 2001
From: Juergen Gross <jgross@suse.com>
Date: Tue, 13 Sep 2022 07:35:08 +0200
Subject: [PATCH 091/126] tools/xenstore: fix connection->id usage

Don't use conn->id for privilege checks, but domain_is_unprivileged().

This is part of XSA-326.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
(cherry picked from commit 3047df38e1991510bc295e3e1bb6b6b6c4a97831)
---
 tools/xenstore/xenstored_control.c     | 2 +-
 tools/xenstore/xenstored_core.h        | 2 +-
 tools/xenstore/xenstored_transaction.c | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/xenstore/xenstored_control.c b/tools/xenstore/xenstored_control.c
index 8e470f2b2056..211fe1fd9b37 100644
--- a/tools/xenstore/xenstored_control.c
+++ b/tools/xenstore/xenstored_control.c
@@ -821,7 +821,7 @@ int do_control(struct connection *conn, struct buffered_data *in)
 	unsigned int cmd, num, off;
 	char **vec = NULL;
 
-	if (conn->id != 0)
+	if (domain_is_unprivileged(conn))
 		return EACCES;
 
 	off = get_string(in, 0);
diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h
index afbd982c2654..c0a056ce13fe 100644
--- a/tools/xenstore/xenstored_core.h
+++ b/tools/xenstore/xenstored_core.h
@@ -118,7 +118,7 @@ struct connection
 	/* The index of pollfd in global pollfd array */
 	int pollfd_idx;
 
-	/* Who am I? 0 for socket connections. */
+	/* Who am I? Domid of connection. */
 	unsigned int id;
 
 	/* Is this connection ignored? */
diff --git a/tools/xenstore/xenstored_transaction.c b/tools/xenstore/xenstored_transaction.c
index 54432907fc76..ee1b09031a3b 100644
--- a/tools/xenstore/xenstored_transaction.c
+++ b/tools/xenstore/xenstored_transaction.c
@@ -477,7 +477,8 @@ int do_transaction_start(struct connection *conn, struct buffered_data *in)
 	if (conn->transaction)
 		return EBUSY;
 
-	if (conn->id && conn->transaction_started > quota_max_transaction)
+	if (domain_is_unprivileged(conn) &&
+	    conn->transaction_started > quota_max_transaction)
 		return ENOSPC;
 
 	/* Attach transaction to input for autofree until it's complete */
-- 
2.37.4