Skip to contentSkip to conversation

Xenstore domains and XS_RESTRICT

DISCUSSION Juergen Gross 7 participants 27 messages Dec 7, 2016 – Jan 18, 2017

lore
Share & tools
lore
#0 lore raw

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */

uint32_t req_id;/* Request identifier, echoed in daemon's response. */ uint32_t tx_id; /* Transaction id (0 if not related to a
transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw
Quoted 10 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

.. which means we can't create new XenStore entries or save off all the XenStore entries?

Quoted 17 lines

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

Quoted 6 lines

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the

Xenstore domain case? As in Linux kernel running the XenStore as an stubdomain?

No, that can't be it. I think you mean that the kernel will have an priviligied connection all the time?

Quoted 11 lines

domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Um, but couldn't a malicious guest decide to craft such packet?

Quoted 6 lines

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

I think I need to wrap my head about your use-case? Could you enumerate what it is?

Thanks.

Quoted 3 lines

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 7 lines · Konrad Rzeszutek Wilk
Quoted 6 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Quoted 7 lines
Quoted 4 lines

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

.. which means we can't create new XenStore entries or save off all the XenStore entries?

Example: qemu for domid 4 is dropping its privilege to that of domid 4 with xenstore running as domain (in contrast to xenstored). If we don't do anything about it dom0 will only be capable to access xenstore with the privileges domid 4 has (e.g. creation of entries outside of /local/domain/4/ will be impossible).

Quoted 19 lines
Quoted 19 lines

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Quoted 7 lines
Quoted 4 lines

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the

Xenstore domain case? As in Linux kernel running the XenStore as an stubdomain?

Xenstore is running in a stubdom and thus dom0 is issuing xenstore commands via the kernel (xenbus driver) to the xenstore domain.

Quoted 2 lines

No, that can't be it. I think you mean that the kernel will have an priviligied connection all the time?

No. the kernel will have just one connection. Privilege is derived from domid (dom0 -> 0).

Quoted 7 lines
Quoted 7 lines

domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

Quoted 6 lines
Quoted 4 lines

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Um, but couldn't a malicious guest decide to craft such packet?

There is no socket connection to xenstore domain.

Quoted 9 lines
Quoted 6 lines

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

I think I need to wrap my head about your use-case? Could you enumerate what it is?

Xenstore isn't running as a daemon in dom0, but as a domain. All domains including dom0 have to connect via xenbus. This means all agents in dom0 accessing xenstore share one connection.

In case xenstore is a daemon in dom0 each agent in dom0 accessing xenstore will open an own socket connection to the daemon, so they can drop their privileges independent from each other.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 13 lines · Juergen Gross
Quoted 12 lines · Konrad Rzeszutek Wilk
Quoted 10 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

Quoted 8 lines
Quoted 2 lines

.. which means we can't create new XenStore entries or save off all the XenStore entries?

Example: qemu for domid 4 is dropping its privilege to that of domid 4 with xenstore running as domain (in contrast to xenstored). If we don't do anything about it dom0 will only be capable to access xenstore with the privileges domid 4 has (e.g. creation of entries outside of /local/domain/4/ will be impossible).

But .. why? Shouldn't it have RWX access to its tree? I should read up on XS_RESTRICT.

Quoted 28 lines
Quoted 20 lines
Quoted 20 lines

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Quoted 7 lines
Quoted 4 lines

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the

Xenstore domain case? As in Linux kernel running the XenStore as an stubdomain?

Quoted 8 lines

Xenstore is running in a stubdom and thus dom0 is issuing xenstore commands via the kernel (xenbus driver) to the xenstore domain.

Quoted 2 lines

No, that can't be it. I think you mean that the kernel will have an priviligied connection all the time?

No. the kernel will have just one connection. Privilege is derived from domid (dom0 -> 0).

What if the XenBus Mirage is the first domain? You could have have it part of the .init section in Xen and it would be started as the first domain.

Depending on the value of domid I think is incorrect.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Um, but couldn't a malicious guest decide to craft such packet?

There is no socket connection to xenstore domain.

Right but it creates its own XenStore ring. Can it send this xsd_sockmsg with domid_id of zero? Or are you saying this is irrelevant becasue what you are interested is for the Linux kernel to filter certain xsd_sockmsg so it won't do something silly?

Quoted 11 lines
Quoted 10 lines
Quoted 7 lines

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

I think I need to wrap my head about your use-case? Could you enumerate what it is?

Quoted 7 lines

Xenstore isn't running as a daemon in dom0, but as a domain. All domains including dom0 have to connect via xenbus. This means all agents in dom0 accessing xenstore share one connection.

In case xenstore is a daemon in dom0 each agent in dom0 accessing xenstore will open an own socket connection to the daemon, so they can drop their privileges independent from each other.

OK, so this all sounds like the OS needs to mediate access? Sorry for being so dense this morning.

This would imply that the kernel driver would need to understand the format and disallow the XS_RESTRICT under certain conditions?

That seems reasonable.

Quoted 3 lines

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
Quoted 17 lines · Konrad Rzeszutek Wilk
Quoted 16 lines · Juergen Gross
Quoted 14 lines · Konrad Rzeszutek Wilk
Quoted 10 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

.. which means we can't create new XenStore entries or save off all the XenStore entries?

Quoted 8 lines
Quoted 5 lines

Example: qemu for domid 4 is dropping its privilege to that of domid 4 with xenstore running as domain (in contrast to xenstored). If we don't do anything about it dom0 will only be capable to access xenstore with the privileges domid 4 has (e.g. creation of entries outside of /local/domain/4/ will be impossible).

But .. why? Shouldn't it have RWX access to its tree? I should read up on XS_RESTRICT.

That would help, yes. :-)

With XS_RESTRICT a privileged connection can drop its privileges to those of a specific domain. This is meant to be used e.g. by qemu together with dropping root privileges after initialization to avoid causing damage to odom0/other domains due to security leaks.

Quoted 35 lines
Quoted 35 lines
Quoted 21 lines
Quoted 21 lines

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Quoted 7 lines
Quoted 4 lines

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the

Xenstore domain case? As in Linux kernel running the XenStore as an stubdomain?

Xenstore is running in a stubdom and thus dom0 is issuing xenstore commands via the kernel (xenbus driver) to the xenstore domain.

Quoted 2 lines

No, that can't be it. I think you mean that the kernel will have an priviligied connection all the time?

Quoted 8 lines
Quoted 2 lines

No. the kernel will have just one connection. Privilege is derived from domid (dom0 -> 0).

What if the XenBus Mirage is the first domain? You could have have it part of the .init section in Xen and it would be started as the first domain.

Depending on the value of domid I think is incorrect.

It is correct. The comparison done is to either 0 or privileged domain (set via start parameter of xenstore domain/daemon).

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines

domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Um, but couldn't a malicious guest decide to craft such packet?

There is no socket connection to xenstore domain.

Right but it creates its own XenStore ring. Can it send this xsd_sockmsg with domid_id of zero? Or are you saying this is irrelevant becasue what you are interested is for the Linux kernel to filter certain xsd_sockmsg so it won't do something silly?

The domid has to be correct for being able to get a grant for its ring. So it isn't transferred via the ring of the new domain, but from dom0 via the XS_INTRODUCE wire command (which is allowed for the privileged domain only).

Quoted 20 lines
Quoted 12 lines
Quoted 11 lines
Quoted 8 lines

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

I think I need to wrap my head about your use-case? Could you enumerate what it is?

Quoted 7 lines

Xenstore isn't running as a daemon in dom0, but as a domain. All domains including dom0 have to connect via xenbus. This means all agents in dom0 accessing xenstore share one connection.

In case xenstore is a daemon in dom0 each agent in dom0 accessing xenstore will open an own socket connection to the daemon, so they can drop their privileges independent from each other.

Quoted 5 lines

OK, so this all sounds like the OS needs to mediate access? Sorry for being so dense this morning.

This would imply that the kernel driver would need to understand the format and disallow the XS_RESTRICT under certain conditions?

Yes. As it does today for start/end of transactions and for setting watches.

Quoted 1 line

That seems reasonable.

I hope so. :-)

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw
In reply to Konrad Rzeszutek Wilk

Konrad Rzeszutek Wilk writes ("Re: Xenstore domains and XS_RESTRICT"):

Quoted 7 lines · Juergen Gross
Quoted 1 line

There is no socket connection to xenstore domain.

Right but it creates its own XenStore ring. Can it send this xsd_sockmsg with domid_id of zero? Or are you saying this is irrelevant becasue what you are interested is for the Linux kernel to filter certain xsd_sockmsg so it won't do something silly?

The latter.

Quoted 2 lines

OK, so this all sounds like the OS needs to mediate access? Sorry for being so dense this morning.

The OS already needs to mediate access for all xenstore commands. The kernel xenbus driver has a list of the commands. Some of them it will "simply" proxy, translating request id and transaction fields, as applicable. Some of them it does something special for. Unknown commands are rejected.

Quoted 2 lines

This would imply that the kernel driver would need to understand the format and disallow the XS_RESTRICT under certain conditions?

There should be a way to tell the kernel driver that the connection should be restricted. XS_RESTRICT is as good as any.

But the XS_RESTRICT command must not be forwarded by the kernel proxy to the real xenstore. Rather, the driver must make an annotation in its client struct instead.

That annotation should result in _every_ proxied xenstore command, from that client, being decorated so as to specify the restriction domain.

There needs to be an extension to the xenstore protocol to support this.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw
Quoted 11 lines · Ian Jackson

Konrad Rzeszutek Wilk writes ("Re: Xenstore domains and XS_RESTRICT"):

Quoted 7 lines · Juergen Gross
Quoted 1 line

There is no socket connection to xenstore domain.

Right but it creates its own XenStore ring. Can it send this xsd_sockmsg with domid_id of zero? Or are you saying this is irrelevant becasue what you are interested is for the Linux kernel to filter certain xsd_sockmsg so it won't do something silly?

The latter.

Quoted 8 lines
Quoted 2 lines

OK, so this all sounds like the OS needs to mediate access? Sorry for being so dense this morning.

The OS already needs to mediate access for all xenstore commands. The kernel xenbus driver has a list of the commands. Some of them it will "simply" proxy, translating request id and transaction fields, as applicable. Some of them it does something special for. Unknown commands are rejected.

Sorry, this isn't true. There is special handling for watch/unwatch and transaction start/end. There is no other command filtering involved, especially no rejection of unknown commands.

Quoted 11 lines
Quoted 3 lines

This would imply that the kernel driver would need to understand the format and disallow the XS_RESTRICT under certain conditions?

There should be a way to tell the kernel driver that the connection should be restricted. XS_RESTRICT is as good as any.

But the XS_RESTRICT command must not be forwarded by the kernel proxy to the real xenstore. Rather, the driver must make an annotation in its client struct instead.

Quoted 6 lines

That annotation should result in _every_ proxied xenstore command, from that client, being decorated so as to specify the restriction domain.

There needs to be an extension to the xenstore protocol to support this.

Right.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#7 lore raw
In reply to Juergen Gross

Juergen Gross writes ("Xenstore domains and XS_RESTRICT"):

Review

Quoted 8 lines

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */

I don't think this is a particularly nice extension. (Also the way you have written it has an endianness hazard.) What if we decide, at some future point, to support domids >2^16 ? That's hard right now but I don't want to make it harder.

I suggest the following protocol extension instead:

Add to xenstore.txt (the list of xenstore commands):

RESTRICTCMD <domid|><realcommand|><realpayload|>

Here <domid|> is a domain id, and <realcommand|> is a command number; both of these are 32-bit integers in host byte order.

This is an instruction to execute the command <realcommand|> with payload <realpayload|>. However, all permissions checking should be done as if the command had been issued by domain <domid|>.

The req_id and tx_id, and (if the command affects watches) any watches that are manipulated, are those of the calling connection. So the reply is sent to the xenstore client (usually, ring client) which sent the RESTRICTCMD command.

If RESTRICTCMD is used to invoke WATCH, the <domid|> from the RESTRICTCMD is attached to the watch, in xenstored. Insofar as watch events are filtered by the permission system, the <domid|> from the RESTRICTCMD is used for watch events originating from such a watch. But the actual watch events are sent to the connection that called RESTRICTCMD.

This is similar in semantics to RESTRICT but applies to this one particular command (and its effects), only.

RESTRICTCMD has no effect on, and is not visible through, the xenstore ring connection of domain <domid|> (if that domain has one).

What do you think ?

There is a command length limit implication but I don't think that's important.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw
Quoted 10 lines · Ian Jackson

Juergen Gross writes ("Xenstore domains and XS_RESTRICT"):

Review

Quoted 8 lines

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
Quoted 4 lines

I don't think this is a particularly nice extension. (Also the way you have written it has an endianness hazard.) What if we decide, at some future point, to support domids >2^16 ? That's hard right now but I don't want to make it harder.

Do we support any big endian systems? I don't think so. An endianess problem could occur only if there are any big endian systems using the old (current) struct xsd_sockmsg.

Regarding size of domid: this is true.

Quoted 9 lines

I suggest the following protocol extension instead:

Add to xenstore.txt (the list of xenstore commands):

RESTRICTCMD <domid|><realcommand|><realpayload|>

Here <domid|> is a domain id, and <realcommand|> is a command number; both of these are 32-bit integers in host byte order.

Hmm, normally parameters outside the command header are transferred using ASCII representation. Do we really want to introduce the first exception?

Quoted 21 lines

This is an instruction to execute the command <realcommand|> with payload <realpayload|>. However, all permissions checking should be done as if the command had been issued by domain <domid|>.

The req_id and tx_id, and (if the command affects watches) any watches that are manipulated, are those of the calling connection. So the reply is sent to the xenstore client (usually, ring client) which sent the RESTRICTCMD command.

If RESTRICTCMD is used to invoke WATCH, the <domid|> from the RESTRICTCMD is attached to the watch, in xenstored. Insofar as watch events are filtered by the permission system, the <domid|> from the RESTRICTCMD is used for watch events originating from such a watch. But the actual watch events are sent to the connection that called RESTRICTCMD.

This is similar in semantics to RESTRICT but applies to this one particular command (and its effects), only.

Quoted 8 lines

RESTRICTCMD has no effect on, and is not visible through, the xenstore ring connection of domain <domid|> (if that domain has one).

What do you think ?

There is a command length limit implication but I don't think that's important.

That was the first problem coming to my mind. OTOH I'm not sure this is really a problem as users of RESTRICTCMD should have no need to use payloads of 4k.

In summary I see advantages for both solutions. IMO the needed changes for my solution will be a little bit smaller, though.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#9 lore raw
Quoted 66 lines · Juergen Gross
Quoted 10 lines · Ian Jackson

Juergen Gross writes ("Xenstore domains and XS_RESTRICT"):

Review

Quoted 8 lines

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
Quoted 4 lines

I don't think this is a particularly nice extension. (Also the way you have written it has an endianness hazard.) What if we decide, at some future point, to support domids >2^16 ? That's hard right now but I don't want to make it harder.

Do we support any big endian systems? I don't think so. An endianess problem could occur only if there are any big endian systems using the old (current) struct xsd_sockmsg.

Regarding size of domid: this is true.

Quoted 9 lines

I suggest the following protocol extension instead:

Add to xenstore.txt (the list of xenstore commands):

RESTRICTCMD <domid|><realcommand|><realpayload|>

Here <domid|> is a domain id, and <realcommand|> is a command number; both of these are 32-bit integers in host byte order.

Hmm, normally parameters outside the command header are transferred using ASCII representation. Do we really want to introduce the first exception?

Quoted 21 lines

This is an instruction to execute the command <realcommand|> with payload <realpayload|>. However, all permissions checking should be done as if the command had been issued by domain <domid|>.

The req_id and tx_id, and (if the command affects watches) any watches that are manipulated, are those of the calling connection. So the reply is sent to the xenstore client (usually, ring client) which sent the RESTRICTCMD command.

If RESTRICTCMD is used to invoke WATCH, the <domid|> from the RESTRICTCMD is attached to the watch, in xenstored. Insofar as watch events are filtered by the permission system, the <domid|> from the RESTRICTCMD is used for watch events originating from such a watch. But the actual watch events are sent to the connection that called RESTRICTCMD.

This is similar in semantics to RESTRICT but applies to this one particular command (and its effects), only.

Quoted 8 lines

RESTRICTCMD has no effect on, and is not visible through, the xenstore ring connection of domain <domid|> (if that domain has one).

What do you think ?

There is a command length limit implication but I don't think that's important.

Quoted 6 lines

That was the first problem coming to my mind. OTOH I'm not sure this is really a problem as users of RESTRICTCMD should have no need to use payloads of 4k.

In summary I see advantages for both solutions. IMO the needed changes for my solution will be a little bit smaller, though.

So we have no resolution which approach should be selected: mine or Ian's (or any other?).

Any preferences?

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#10 lore raw
In reply to Juergen Gross
Quoted 38 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

Quoted 5 lines

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

I'm slightly concerned about this non-unified model -- I would rather xenstored only needs to deal with "virtual connection", regardless of the interface (socket or kernel) they use.

I'm not convinced that socket-based distinction is good enough -- what if some program tries to multiplex the socket? Is that not possible at the moment?

(I can't find XS_RESTRICT in xenstore.txt, so I'm not sure if I'm talking nonsense)

Quoted 8 lines

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#11 lore raw
Quoted 45 lines · Wei Liu
Quoted 38 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

Quoted 5 lines

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Quoted 3 lines

I'm slightly concerned about this non-unified model -- I would rather xenstored only needs to deal with "virtual connection", regardless of the interface (socket or kernel) they use.

Rejecting XS_RESTRICT for a non-socket connection is mandatory to ensure a XS_RESTRICT user on an old kernel not knowing about it can't drop the privilege of all other user's on that system, too.

Quoted 3 lines

I'm not convinced that socket-based distinction is good enough -- what if some program tries to multiplex the socket? Is that not possible at the moment?

In this case it would have to handle XS_RESTRICT the same way as the kernel should do it.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#12 lore raw
Quoted 46 lines · Juergen Gross
Quoted 45 lines · Wei Liu
Quoted 43 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Quoted 8 lines
Quoted 3 lines

I'm slightly concerned about this non-unified model -- I would rather xenstored only needs to deal with "virtual connection", regardless of the interface (socket or kernel) they use.

Rejecting XS_RESTRICT for a non-socket connection is mandatory to ensure a XS_RESTRICT user on an old kernel not knowing about it can't drop the privilege of all other user's on that system, too.

This highlights the flaw in this command. IMHO it would make sense to invent something new other than extending something that is already deemed inadequate.

There is no documentation about the semantics of XS_RESTRICT, which is another reason to not touch it.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#13 lore raw
Quoted 51 lines · Wei Liu
Quoted 50 lines · Juergen Gross
Quoted 48 lines · Wei Liu
Quoted 38 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

Quoted 5 lines

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

I'm slightly concerned about this non-unified model -- I would rather xenstored only needs to deal with "virtual connection", regardless of the interface (socket or kernel) they use.

Quoted 8 lines
Quoted 4 lines

Rejecting XS_RESTRICT for a non-socket connection is mandatory to ensure a XS_RESTRICT user on an old kernel not knowing about it can't drop the privilege of all other user's on that system, too.

This highlights the flaw in this command. IMHO it would make sense to invent something new other than extending something that is already deemed inadequate.

I think this "flaw" is present for any new Xenstore command modifying the state of a connection for all or some following commands: kernel and Xen versions are not in sync and so you'd need such mechanisms.

Quoted 2 lines

There is no documentation about the semantics of XS_RESTRICT, which is another reason to not touch it.

Yes. See https://lists.xen.org/archives/html/xen-devel/2016-06/msg03487.html

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#14 lore raw
In reply to Juergen Gross

Juergen Gross writes ("Re: Xenstore domains and XS_RESTRICT"):

Quoted 3 lines

Rejecting XS_RESTRICT for a non-socket connection is mandatory to ensure a XS_RESTRICT user on an old kernel not knowing about it can't drop the privilege of all other user's on that system, too.

Kernels need to proxy all commands from their users, so they should have a table (usually a switch statement) of supported commands. New commands are therefore unavailable until the kernel is updated.

I haven't checked the Linux xenbus chardev driver to see if it is correct ...

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#15 lore raw
Quoted 8 lines · Ian Jackson

Juergen Gross writes ("Re: Xenstore domains and XS_RESTRICT"):

Quoted 3 lines

Rejecting XS_RESTRICT for a non-socket connection is mandatory to ensure a XS_RESTRICT user on an old kernel not knowing about it can't drop the privilege of all other user's on that system, too.

Kernels need to proxy all commands from their users, so they should have a table (usually a switch statement) of supported commands. New commands are therefore unavailable until the kernel is updated.

Uuh, really?

I think this is true for only very few commands needing special treatment (right now those are: start/stop transaction, register/ unregister watch). All other commands can just be passed through without any need for special (command specific) treatment in the kernel.

XS_RESTRICT would be another command needing special treatment.

XS_DIRECTORY_PART introduced recently is a good example for a command not needing any special kernel treatment. If the kernel would have a positive list of commands to pass through this command would be available on new kernels only limiting e.g. dom0 functionality without any special need.

Quoted 2 lines

I haven't checked the Linux xenbus chardev driver to see if it is correct ...

In your sense: no. For any non-special new Xenstore commands: yes.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#16 lore raw
In reply to Juergen Gross
Quoted 43 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Quoted 5 lines

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

As I don't get any further constructive responses even after asking for
them: would patches removing all XS_RESTRICT support be accepted?

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#17 lore raw
Quoted 44 lines · Juergen Gross
Quoted 43 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Quoted 9 lines
Quoted 5 lines

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

As I don't get any further constructive responses even after asking for
them: would patches removing all XS_RESTRICT support be accepted?

We don't need to actually remove it, do we? If XS_RESTRICT is not supported by xenstored, the client would get meaningful error code. A patch to deprecate that command should be good enough, right?

And sorry for the late reply, I'm still mulling over your proposal, I will try to respond as soon as possible.

Wei.

Quoted 3 lines

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#18 lore raw
Quoted 51 lines · Wei Liu
Quoted 50 lines · Juergen Gross
Quoted 48 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

Quoted 7 lines
Quoted 3 lines

As I don't get any further constructive responses even after asking for
them: would patches removing all XS_RESTRICT support be accepted?

We don't need to actually remove it, do we? If XS_RESTRICT is not supported by xenstored, the client would get meaningful error code. A patch to deprecate that command should be good enough, right?

Uuh, no.

oxenstored does support XS_RESTRICT. The longer it stays the better the chances someone is using it.

Quoted 2 lines

And sorry for the late reply, I'm still mulling over your proposal, I will try to respond as soon as possible.

I thought a little bit further: the idea of XS_RESTRICT is to avoid qemu being capable to overwrite any Xenstore entries of other domains including dom0.

I fail to see how this should work with qemu-based backends (qdisk, pvusb), as those rely on paths in Xenstore writable by dom0 only.

We already have a mechanism to de-privilege the device model of a HVM domain without hurting the backends: ioemu-stubdom. So I believe we should try to make qmeu upstream usable in stubdom instead of introducing mechanisms limited in usability ("if you want a secure device model you can't use features x, y and z.").

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#19 lore raw
Quoted 56 lines · Juergen Gross
Quoted 55 lines · Wei Liu
Quoted 53 lines · Juergen Gross
Quoted 43 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Quoted 5 lines

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

As I don't get any further constructive responses even after asking for
them: would patches removing all XS_RESTRICT support be accepted?

Quoted 9 lines
Quoted 3 lines

We don't need to actually remove it, do we? If XS_RESTRICT is not supported by xenstored, the client would get meaningful error code. A patch to deprecate that command should be good enough, right?

Uuh, no.

oxenstored does support XS_RESTRICT. The longer it stays the better the chances someone is using it.

Right. That's what I'm getting at.

As a developer I'm in favour of ripping XS_RESTRICT out completely, but as a maintainer I'm a bit uncomfortable with that...

If current users are happy with this limiting interface, let them use it. We just need to provide a better alternative for future users.

And even if we want to eventually remove it, we should try our best provide an upgrade path. In this particular case, I think whatever scheme we agree on is going to be a natural upgrade path. We can choose to either keep XS_RESTRICT or remove it after that.

I know we're paying for passed mistakes, but the above plan doesn't seem to increase your workload. I have the feeling that you're in favour of working on something more adequate, and I'm in favour of that, too.

Does that make sense?

Quoted 7 lines
Quoted 2 lines

And sorry for the late reply, I'm still mulling over your proposal, I will try to respond as soon as possible.

I thought a little bit further: the idea of XS_RESTRICT is to avoid qemu being capable to overwrite any Xenstore entries of other domains including dom0.

Quoted 9 lines

I fail to see how this should work with qemu-based backends (qdisk, pvusb), as those rely on paths in Xenstore writable by dom0 only.

We already have a mechanism to de-privilege the device model of a HVM domain without hurting the backends: ioemu-stubdom. So I believe we should try to make qmeu upstream usable in stubdom instead of introducing mechanisms limited in usability ("if you want a secure device model you can't use features x, y and z.").

Right, we would like to see that happen, too. This is an useful thing in and of itself.

Wei.

Quoted 2 lines

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#20 lore raw
Quoted 67 lines · Wei Liu
Quoted 56 lines · Juergen Gross
Quoted 55 lines · Wei Liu
Quoted 53 lines · Juergen Gross
Quoted 43 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Quoted 5 lines

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

As I don't get any further constructive responses even after asking for
them: would patches removing all XS_RESTRICT support be accepted?

Quoted 9 lines
Quoted 3 lines

We don't need to actually remove it, do we? If XS_RESTRICT is not supported by xenstored, the client would get meaningful error code. A patch to deprecate that command should be good enough, right?

Uuh, no.

oxenstored does support XS_RESTRICT. The longer it stays the better the chances someone is using it.

Quoted 7 lines

Right. That's what I'm getting at.

As a developer I'm in favour of ripping XS_RESTRICT out completely, but as a maintainer I'm a bit uncomfortable with that...

If current users are happy with this limiting interface, let them use it. We just need to provide a better alternative for future users.

I'm not sure it is a good decision to let them use XS_RESTRICT. It is an interface with weird consequences in some cases which are not visible until some rare use cases (like hot-plugging a qdisk) are effective.

Quoted 4 lines

And even if we want to eventually remove it, we should try our best provide an upgrade path. In this particular case, I think whatever scheme we agree on is going to be a natural upgrade path. We can choose to either keep XS_RESTRICT or remove it after that.

Today XS_RESTRICT is encapsulated by xs_restrict(). We could keep this function and let it return false always. This way XS_RESTRICT could be removed without breaking any current users as xs_restrict() is returning false with xenstored today.

Quoted 3 lines

I know we're paying for passed mistakes, but the above plan doesn't seem to increase your workload. I have the feeling that you're in favour of working on something more adequate, and I'm in favour of that, too.

I'm not concerned about my workload. :-)

I'd like to have a solution for the original problem (reduction of possible problems due to a compromised device model) without having to limit the overall functionality (Xenstore not capable to run as stubdom, no qemu-based backends possible).

Quoted 19 lines

Does that make sense?

Quoted 7 lines
Quoted 2 lines

And sorry for the late reply, I'm still mulling over your proposal, I will try to respond as soon as possible.

I thought a little bit further: the idea of XS_RESTRICT is to avoid qemu being capable to overwrite any Xenstore entries of other domains including dom0.

Quoted 9 lines

I fail to see how this should work with qemu-based backends (qdisk, pvusb), as those rely on paths in Xenstore writable by dom0 only.

We already have a mechanism to de-privilege the device model of a HVM domain without hurting the backends: ioemu-stubdom. So I believe we should try to make qmeu upstream usable in stubdom instead of introducing mechanisms limited in usability ("if you want a secure device model you can't use features x, y and z.").

Quoted 2 lines

Right, we would like to see that happen, too. This is an useful thing in and of itself.

Might be not so easy... :-(

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#21 lore raw
Quoted 76 lines · Juergen Gross
Quoted 63 lines · Wei Liu
Quoted 54 lines · Juergen Gross
Quoted 53 lines · Wei Liu
Quoted 52 lines · Juergen Gross
Quoted 43 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Quoted 5 lines

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

As I don't get any further constructive responses even after asking for
them: would patches removing all XS_RESTRICT support be accepted?

Quoted 8 lines
Quoted 3 lines

We don't need to actually remove it, do we? If XS_RESTRICT is not supported by xenstored, the client would get meaningful error code. A patch to deprecate that command should be good enough, right?

Uuh, no.

oxenstored does support XS_RESTRICT. The longer it stays the better the chances someone is using it.

Quoted 7 lines

Right. That's what I'm getting at.

As a developer I'm in favour of ripping XS_RESTRICT out completely, but as a maintainer I'm a bit uncomfortable with that...

If current users are happy with this limiting interface, let them use it. We just need to provide a better alternative for future users.

I'm not sure it is a good decision to let them use XS_RESTRICT. It is an interface with weird consequences in some cases which are not visible until some rare use cases (like hot-plugging a qdisk) are effective.

Quoted 8 lines
Quoted 4 lines

And even if we want to eventually remove it, we should try our best provide an upgrade path. In this particular case, I think whatever scheme we agree on is going to be a natural upgrade path. We can choose to either keep XS_RESTRICT or remove it after that.

Today XS_RESTRICT is encapsulated by xs_restrict(). We could keep this function and let it return false always. This way XS_RESTRICT could be removed without breaking any current users as xs_restrict() is returning false with xenstored today.

I don't think XS_RESTRICT is actually used by anyone.

It was added to oxenstored in the dim and distant past, but nothing I can find in XenServer uses it. In particular, its intended usecase (for deprivileging qemu) doesn't work because qemu currently needs access to dom0 keys to work.

I'd tentatively rip it out. No point keeping unused broken functionality around and getting in the way of fixing the problem properly.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#22 lore raw
Quoted 88 lines · Andrew Cooper
Quoted 76 lines · Juergen Gross
Quoted 63 lines · Wei Liu
Quoted 54 lines · Juergen Gross
Quoted 53 lines · Wei Liu
Quoted 52 lines · Juergen Gross
Quoted 43 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Quoted 5 lines

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

As I don't get any further constructive responses even after asking for
them: would patches removing all XS_RESTRICT support be accepted?

Quoted 8 lines
Quoted 3 lines

We don't need to actually remove it, do we? If XS_RESTRICT is not supported by xenstored, the client would get meaningful error code. A patch to deprecate that command should be good enough, right?

Uuh, no.

oxenstored does support XS_RESTRICT. The longer it stays the better the chances someone is using it.

Quoted 7 lines

Right. That's what I'm getting at.

As a developer I'm in favour of ripping XS_RESTRICT out completely, but as a maintainer I'm a bit uncomfortable with that...

If current users are happy with this limiting interface, let them use it. We just need to provide a better alternative for future users.

I'm not sure it is a good decision to let them use XS_RESTRICT. It is an interface with weird consequences in some cases which are not visible until some rare use cases (like hot-plugging a qdisk) are effective.

Quoted 8 lines
Quoted 4 lines

And even if we want to eventually remove it, we should try our best provide an upgrade path. In this particular case, I think whatever scheme we agree on is going to be a natural upgrade path. We can choose to either keep XS_RESTRICT or remove it after that.

Today XS_RESTRICT is encapsulated by xs_restrict(). We could keep this function and let it return false always. This way XS_RESTRICT could be removed without breaking any current users as xs_restrict() is returning false with xenstored today.

I don't think XS_RESTRICT is actually used by anyone.

Quoted 7 lines

It was added to oxenstored in the dim and distant past, but nothing I can find in XenServer uses it. In particular, its intended usecase (for deprivileging qemu) doesn't work because qemu currently needs access to dom0 keys to work.

I'd tentatively rip it out. No point keeping unused broken functionality around and getting in the way of fixing the problem properly.

I think I'd go with "Rip it out and if anyone complains, we can figure out what to do (including puting it back in)".

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#23 lore raw
Quoted 94 lines · George Dunlap
Quoted 93 lines · Andrew Cooper
Quoted 76 lines · Juergen Gross
Quoted 63 lines · Wei Liu
Quoted 54 lines · Juergen Gross
Quoted 53 lines · Wei Liu
Quoted 52 lines · Juergen Gross
Quoted 43 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Quoted 5 lines

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

As I don't get any further constructive responses even after asking for
them: would patches removing all XS_RESTRICT support be accepted?

Quoted 8 lines
Quoted 3 lines

We don't need to actually remove it, do we? If XS_RESTRICT is not supported by xenstored, the client would get meaningful error code. A patch to deprecate that command should be good enough, right?

Uuh, no.

oxenstored does support XS_RESTRICT. The longer it stays the better the chances someone is using it.

Quoted 7 lines

Right. That's what I'm getting at.

As a developer I'm in favour of ripping XS_RESTRICT out completely, but as a maintainer I'm a bit uncomfortable with that...

If current users are happy with this limiting interface, let them use it. We just need to provide a better alternative for future users.

I'm not sure it is a good decision to let them use XS_RESTRICT. It is an interface with weird consequences in some cases which are not visible until some rare use cases (like hot-plugging a qdisk) are effective.

Quoted 8 lines
Quoted 4 lines

And even if we want to eventually remove it, we should try our best provide an upgrade path. In this particular case, I think whatever scheme we agree on is going to be a natural upgrade path. We can choose to either keep XS_RESTRICT or remove it after that.

Today XS_RESTRICT is encapsulated by xs_restrict(). We could keep this function and let it return false always. This way XS_RESTRICT could be removed without breaking any current users as xs_restrict() is returning false with xenstored today.

I don't think XS_RESTRICT is actually used by anyone.

It was added to oxenstored in the dim and distant past, but nothing I can find in XenServer uses it. In particular, its intended usecase (for deprivileging qemu) doesn't work because qemu currently needs access to dom0 keys to work.

Quoted 5 lines
Quoted 2 lines

I'd tentatively rip it out. No point keeping unused broken functionality around and getting in the way of fixing the problem properly.

I think I'd go with "Rip it out and if anyone complains, we can figure out what to do (including puting it back in)".

I'll post a patch to do this. In case someone is strictly against deleting XS_RESTRICT he can still NAK the patch, right?

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#24 lore raw
Quoted 95 lines · Juergen Gross
Quoted 94 lines · George Dunlap
Quoted 93 lines · Andrew Cooper
Quoted 76 lines · Juergen Gross
Quoted 63 lines · Wei Liu
Quoted 54 lines · Juergen Gross
Quoted 53 lines · Wei Liu
Quoted 52 lines · Juergen Gross
Quoted 43 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

Quoted 5 lines

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

As I don't get any further constructive responses even after asking for
them: would patches removing all XS_RESTRICT support be accepted?

Quoted 8 lines
Quoted 3 lines

We don't need to actually remove it, do we? If XS_RESTRICT is not supported by xenstored, the client would get meaningful error code. A patch to deprecate that command should be good enough, right?

Uuh, no.

oxenstored does support XS_RESTRICT. The longer it stays the better the chances someone is using it.

Quoted 7 lines

Right. That's what I'm getting at.

As a developer I'm in favour of ripping XS_RESTRICT out completely, but as a maintainer I'm a bit uncomfortable with that...

If current users are happy with this limiting interface, let them use it. We just need to provide a better alternative for future users.

I'm not sure it is a good decision to let them use XS_RESTRICT. It is an interface with weird consequences in some cases which are not visible until some rare use cases (like hot-plugging a qdisk) are effective.

Quoted 8 lines
Quoted 4 lines

And even if we want to eventually remove it, we should try our best provide an upgrade path. In this particular case, I think whatever scheme we agree on is going to be a natural upgrade path. We can choose to either keep XS_RESTRICT or remove it after that.

Today XS_RESTRICT is encapsulated by xs_restrict(). We could keep this function and let it return false always. This way XS_RESTRICT could be removed without breaking any current users as xs_restrict() is returning false with xenstored today.

I don't think XS_RESTRICT is actually used by anyone.

It was added to oxenstored in the dim and distant past, but nothing I can find in XenServer uses it. In particular, its intended usecase (for deprivileging qemu) doesn't work because qemu currently needs access to dom0 keys to work.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

I'd tentatively rip it out. No point keeping unused broken functionality around and getting in the way of fixing the problem properly.

I think I'd go with "Rip it out and if anyone complains, we can figure out what to do (including puting it back in)".

I'll post a patch to do this. In case someone is strictly against deleting XS_RESTRICT he can still NAK the patch, right?

Yes, that's correct.

Quoted 3 lines

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#25 lore raw
In reply to Juergen Gross
Quoted 68 lines · Juergen Gross
Quoted 51 lines · Wei Liu
Quoted 50 lines · Juergen Gross
Quoted 48 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

Quoted 7 lines
Quoted 3 lines

As I don't get any further constructive responses even after asking for
them: would patches removing all XS_RESTRICT support be accepted?

We don't need to actually remove it, do we? If XS_RESTRICT is not supported by xenstored, the client would get meaningful error code. A patch to deprecate that command should be good enough, right?

Uuh, no.

oxenstored does support XS_RESTRICT. The longer it stays the better the chances someone is using it.

Quoted 2 lines

And sorry for the late reply, I'm still mulling over your proposal, I will try to respond as soon as possible.

Quoted 6 lines

I thought a little bit further: the idea of XS_RESTRICT is to avoid qemu being capable to overwrite any Xenstore entries of other domains including dom0.

I fail to see how this should work with qemu-based backends (qdisk, pvusb), as those rely on paths in Xenstore writable by dom0 only.

It does not work. However, QEMU based backends can be run on a separate QEMU. Patches were submitted by IanJ and me to run 2 QEMUs per domain, one to provide emulation, the other to provide the backends. Not sure what happen to them, but they were more then prototypes.

Quoted 5 lines

We already have a mechanism to de-privilege the device model of a HVM domain without hurting the backends: ioemu-stubdom. So I believe we should try to make qmeu upstream usable in stubdom instead of introducing mechanisms limited in usability ("if you want a secure device model you can't use features x, y and z.").

Yes, but ioemu-stubdoms have drawbacks that make them not viable in many scenarios. There are reasons why they are not enabled by default. XS_RESTRICT should not replace, but complement ioemu-stubdoms. If we remove XS_RESTRICT, what's the plan to make QEMU in Dom0 secure by default?

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#26 lore raw
Quoted 88 lines · Stefano Stabellini
Quoted 68 lines · Juergen Gross
Quoted 51 lines · Wei Liu
Quoted 50 lines · Juergen Gross
Quoted 48 lines · Juergen Gross

Hi,

today the XS_RESTRICT wire command of Xenstore is supported by oxenstored only to drop the privilege of a connection to that of the domid given as a parameter to the command.

Using this mechanism with Xenstore running in a stubdom will lead to problems as instead of only a dom0 process dropping its privileges the privileges of dom0 will be dropped (all dom0 Xenstore requests share the same connection).

In order to solve the problem I suggest the following change to the Xenstore wire protocol:

struct xsd_sockmsg
{

(quoted diff) +2 -1
-    uint32_t type;  /* XS_??? */
+    uint16_t type;  /* XS_??? */
+    uint16_t domid; /* Use privileges of this domain */
     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
     uint32_t tx_id; /* Transaction id (0 if not related to a

transaction). */
uint32_t len; /* Length of data following this. */

/* Generally followed by nul-terminated string(s). */
};

domid will normally be zero having the same effect as today.

Using XS_RESTRICT via a socket connection will run as today by dropping the privileges of that connection.

Using XS_RESTRICT via the kernel (Xenstore domain case) will save the domid given as parameter in the connection specific private kernel structure. All future Xenstore commands of the connection will have this domid set in xsd_sockmsg. The kernel will never forward the XS_RESTRICT command to Xenstore.

A domid other than 0 in xsd_sockmsg will be handled by Xenstore to use the privileges of that domain. Specifying a domid in xsd_sockmsg is allowed for privileged domain only, of course. XS_RESTRICT via a non-socket connection will be rejected in all cases.

The needed modifications for Xenstore and the kernel are rather small. As there is currently no Xenstore domain available supporting XS_RESTRICT there are no compatibility issues to expect.

Thoughts?

Quoted 7 lines
Quoted 3 lines

As I don't get any further constructive responses even after asking for
them: would patches removing all XS_RESTRICT support be accepted?

We don't need to actually remove it, do we? If XS_RESTRICT is not supported by xenstored, the client would get meaningful error code. A patch to deprecate that command should be good enough, right?

Uuh, no.

oxenstored does support XS_RESTRICT. The longer it stays the better the chances someone is using it.

Quoted 2 lines

And sorry for the late reply, I'm still mulling over your proposal, I will try to respond as soon as possible.

Quoted 6 lines

I thought a little bit further: the idea of XS_RESTRICT is to avoid qemu being capable to overwrite any Xenstore entries of other domains including dom0.

I fail to see how this should work with qemu-based backends (qdisk, pvusb), as those rely on paths in Xenstore writable by dom0 only.

It does not work. However, QEMU based backends can be run on a separate QEMU. Patches were submitted by IanJ and me to run 2 QEMUs per domain, one to provide emulation, the other to provide the backends. Not sure what happen to them, but they were more then prototypes.

Quoted 5 lines

We already have a mechanism to de-privilege the device model of a HVM domain without hurting the backends: ioemu-stubdom. So I believe we should try to make qmeu upstream usable in stubdom instead of introducing mechanisms limited in usability ("if you want a secure device model you can't use features x, y and z.").

Quoted 5 lines

Yes, but ioemu-stubdoms have drawbacks that make them not viable in many scenarios. There are reasons why they are not enabled by default. XS_RESTRICT should not replace, but complement ioemu-stubdoms. If we remove XS_RESTRICT, what's the plan to make QEMU in Dom0 secure by default?

Currently none. OTOH there is no plan how to make XS_RESTRICT work in other cases like Xenstore domain.

We need to design a solution which has no such drawbacks. We don't have to implement them all from beginning, but we should know how to do it. Otherwise something like XS_RESTRICT will be the result which isn't activated as default as it isn't working for all cases.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel