aboutsummaryrefslogtreecommitdiffstats
path: root/tools/ocaml/xenstored/process.ml
diff options
context:
space:
mode:
authorIan Jackson <ian.jackson@eu.citrix.com>2013-09-03 11:55:48 +0100
committerIan Jackson <Ian.Jackson@eu.citrix.com>2013-09-03 11:55:48 +0100
commit9f93027afd796a98d7b92898f4ccc772796a4874 (patch)
tree673aca110f182ea92052bbf3729f3622b54de9d6 /tools/ocaml/xenstored/process.ml
parent56b2771863b7835faf6fa07290bcacb3a68a8326 (diff)
downloadxen-9f93027afd796a98d7b92898f4ccc772796a4874.tar.gz
xen-9f93027afd796a98d7b92898f4ccc772796a4874.tar.bz2
xen-9f93027afd796a98d7b92898f4ccc772796a4874.zip
oxenstored: Protect oxenstored from malicious domains.
add check logic when read from IO ring, and if error happens, then mark the reading connection as "bad", Unless vm reboot, oxenstored will not handle message from this connection any more. xs_ring_stubs.c: add a more strict check on ring reading connection.ml, domain.ml: add getter and setter for bad flag process.ml: if exception raised when reading from domain's ring, mark this domain as "bad" xenstored.ml: if a domain is marked as "bad", do not handle it. Signed-off-by: John Liu <john.liuqiming@huawei.com> Acked-by: David Scott <dave.scott@eu.citrix.com> (cherry picked from commit 704302ce9404c73cfb687d31adcf67094ab5bb53) (cherry picked from commit a978634bee4db6c5e0ceeb66adcc5114f3f9bc48) Conflicts: tools/ocaml/xenstored/domain.ml Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/ocaml/xenstored/process.ml')
-rw-r--r--tools/ocaml/xenstored/process.ml12
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/ocaml/xenstored/process.ml b/tools/ocaml/xenstored/process.ml
index a4ff741264..89db56cd85 100644
--- a/tools/ocaml/xenstored/process.ml
+++ b/tools/ocaml/xenstored/process.ml
@@ -374,7 +374,17 @@ let write_answer_log ~ty ~tid ~con ~data =
Logging.xb_answer ~ty ~tid ~con:(Connection.get_domstr con) data
let do_input store cons doms con =
- if Connection.do_input con then (
+ let newpacket =
+ try
+ Connection.do_input con
+ with Failure exp ->
+ error "caught exception %s" exp;
+ error "got a bad client %s" (sprintf "%-8s" (Connection.get_domstr con));
+ Connection.mark_as_bad con;
+ false
+ in
+
+ if newpacket then (
let packet = Connection.pop_in con in
let tid, rid, ty, data = Xenbus.Xb.Packet.unpack packet in
(* As we don't log IO, do not call an unnecessary sanitize_data