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

[xen stable-4.12] tools/ocaml/libs/xb: Do not crash after xenbus is unmapped

commit f66542f5d2217f3868d78ff64d11a2a02674fed9
Author:     Edwin Török <edvin.torok@xxxxxxxxxx>
AuthorDate: Fri Jan 15 18:23:10 2021 +0000
Commit:     Ian Jackson <iwj@xxxxxxxxxxxxxx>
CommitDate: Fri Mar 19 13:46:44 2021 +0000

    tools/ocaml/libs/xb: Do not crash after xenbus is unmapped
    Xenmmap.unmap sets the address to MAP_FAILED in xenmmap_stubs.c.  If due to 
    bug there were still references to the Xenbus and we attempt to use it then 
    crash.  Raise an exception instead of crashing.
    Signed-off-by: Edwin Török <edvin.torok@xxxxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    (cherry picked from commit 5e317896342d553f0b55f72948bbf93a0f1147d3)
 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 
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);
generated by git-patchbot for /home/xen/git/xen.git#stable-4.12



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