tools/ocaml/xenstored: clean up permissions for dead domains
authorEdwin Török <edvin.torok@citrix.com>
Tue, 15 Dec 2020 13:08:03 +0000 (14:08 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 15 Dec 2020 13:08:03 +0000 (14:08 +0100)
commitdc871dda66a1ac1e0fc1ca5e35e380a145aaa739
tree61a2a12090efcd9cc622267b02cef751fb8638bf
parentb1c5e402c488e4d2b78de1d08b9e98feed136ee7
tools/ocaml/xenstored: clean up permissions for dead domains

domain ids are prone to wrapping (15-bits), and with sufficient number
of VMs in a reboot loop it is possible to trigger it.  Xenstore entries
may linger after a domain dies, until a toolstack cleans it up. During
this time there is a window where a wrapped domid could access these
xenstore keys (that belonged to another VM).

To prevent this do a cleanup when a domain dies:
 * walk the entire xenstore tree and update permissions for all nodes
   * if the dead domain had an ACL entry: remove it
   * if the dead domain was the owner: change the owner to Dom0

This is done without quota checks or a transaction. Quota checks would
be a no-op (either the domain is dead, or it is Dom0 where they are not
enforced).  Transactions are not needed, because this is all done
atomically by oxenstored's single thread.

The xenstore entries owned by the dead domain are not deleted, because
that could confuse a toolstack / backends that are still bound to it
(or generate unexpected watch events). It is the responsibility of a
toolstack to remove the xenstore entries themselves.

This is part of XSA-322.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
tools/ocaml/xenstored/perms.ml
tools/ocaml/xenstored/process.ml
tools/ocaml/xenstored/store.ml
tools/ocaml/xenstored/xenstored.ml