[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 1/4] tools/ocaml/libs/xb: do not crash after xenbus is unmapped


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Edwin Török <edvin.torok@xxxxxxxxxx>
  • Date: Fri, 15 Jan 2021 22:29:06 +0000
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Edwin Török <edvin.torok@xxxxxxxxxx>, "Christian Lindig" <christian.lindig@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, "Ian Jackson" <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 15 Jan 2021 22:52:44 +0000
  • Ironport-sdr: 38anpzmgEYm8RC8Iis3iaGr6eVYc2bd8LxVkaIVgGeoD/pNFjIQR4yS69KRxzhioTeAC5+4gS/ Hj5zYoImDN9l6+1npPaVAYxtu04FVAcHGByMckRUTwSNzpdyrxz6t80SAe30pofSha9SFCcyKE 0jtzlsBrDbgeQ0nNPxJPXL+/3qWXp2T78oxyk4rNY95oTIY+Oi56b1fAEEpr7kEAh6U1zyZLUu ubLKDYmSOENgXHcdi/E3AoUasW9oest8gKslDov1b9nDZwZ0L4V5ALvVPnn2zRpVyNqUuIZ9d0 +pU=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Xenmmap.unmap sets the address to MAP_FAILED in xenmmap_stubs.c.
If due to a bug there were still references to the Xenbus and we attempt
to use it then we crash.
Raise an exception instead of crashing.

(My initial version of fuzz testing had such a bug)

Signed-off-by: Edwin Török <edvin.torok@xxxxxxxxxx>
---
 tools/ocaml/libs/xb/xs_ring_stubs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/ocaml/libs/xb/xs_ring_stubs.c 
b/tools/ocaml/libs/xb/xs_ring_stubs.c
index 7537a23949..7a91fdee75 100644
--- a/tools/ocaml/libs/xb/xs_ring_stubs.c
+++ b/tools/ocaml/libs/xb/xs_ring_stubs.c
@@ -32,6 +32,7 @@
 #include <caml/fail.h>
 #include <caml/callback.h>
 
+#include <sys/mman.h>
 #include "mmap_stubs.h"
 
 #define GET_C_STRUCT(a) ((struct mmap_interface *) a)
@@ -166,6 +167,8 @@ CAMLprim value ml_interface_set_server_features(value 
interface, value v)
 {
        CAMLparam2(interface, v);
        struct xenstore_domain_interface *intf = GET_C_STRUCT(interface)->addr;
+       if (intf == (void*)MAP_FAILED)
+               caml_failwith("Interface closed");
 
        intf->server_features = Int_val(v);
 
-- 
2.29.2




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.