aboutsummaryrefslogtreecommitdiffstats
path: root/tools/ocaml/libs
diff options
context:
space:
mode:
author=John Liu <john.liuqiming@huawei.com>2013-07-22 22:23:10 +0100
committerIan Campbell <ian.campbell@citrix.com>2013-07-22 22:23:10 +0100
commit704302ce9404c73cfb687d31adcf67094ab5bb53 (patch)
tree28ba781031c1ad021085e36cb2c0ab55340c92de /tools/ocaml/libs
parent61917a0802b93cebd596c6c71aa13df428149f67 (diff)
downloadxen-704302ce9404c73cfb687d31adcf67094ab5bb53.tar.gz
xen-704302ce9404c73cfb687d31adcf67094ab5bb53.tar.bz2
xen-704302ce9404c73cfb687d31adcf67094ab5bb53.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>
Diffstat (limited to 'tools/ocaml/libs')
-rw-r--r--tools/ocaml/libs/xb/xs_ring_stubs.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/ocaml/libs/xb/xs_ring_stubs.c b/tools/ocaml/libs/xb/xs_ring_stubs.c
index fdd9983d1a..8bd1047490 100644
--- a/tools/ocaml/libs/xb/xs_ring_stubs.c
+++ b/tools/ocaml/libs/xb/xs_ring_stubs.c
@@ -45,6 +45,10 @@ static int xs_ring_read(struct mmap_interface *interface,
cons = *(volatile uint32*)&intf->req_cons;
prod = *(volatile uint32*)&intf->req_prod;
xen_mb();
+
+ if ((prod - cons) > XENSTORE_RING_SIZE)
+ return -1;
+
if (prod == cons)
return 0;
cons = MASK_XENSTORE_IDX(cons);
@@ -94,7 +98,7 @@ CAMLprim value ml_interface_read(value interface, value buffer, value len)
res = xs_ring_read(GET_C_STRUCT(interface),
String_val(buffer), Int_val(len));
if (res == -1)
- caml_failwith("huh");
+ caml_failwith("bad connection");
result = Val_int(res);
CAMLreturn(result);
}