From patchwork Fri Jan 15 22:29:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= X-Patchwork-Id: 12024307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2150FC433E0 for ; Fri, 15 Jan 2021 22:52:52 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E13BD23128 for ; Fri, 15 Jan 2021 22:52:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E13BD23128 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.68727.123140 (Exim 4.92) (envelope-from ) id 1l0XxU-0001oD-LO; Fri, 15 Jan 2021 22:52:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 68727.123140; Fri, 15 Jan 2021 22:52:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l0XxU-0001o4-Ex; Fri, 15 Jan 2021 22:52:44 +0000 Received: by outflank-mailman (input) for mailman id 68727; Fri, 15 Jan 2021 22:52:43 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l0XxS-0001Wj-VC for xen-devel@lists.xenproject.org; Fri, 15 Jan 2021 22:52:42 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ce39791c-cde2-44e2-bddc-f6b8853784ee; Fri, 15 Jan 2021 22:52:31 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ce39791c-cde2-44e2-bddc-f6b8853784ee DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1610751150; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yOHeqFGiMe4hZS6YwMQMyCOdiJ0wM3c0HqxPstrpIhc=; b=ChfqWcI3+UBe+xsqzxLXcI3S9YDZ2SUz6+sd+Um9bpqjjBZUr+xiR2h3 B5yrZgiTB8O/acoXVw5HvEoVnwFgwbupeQ/stb89hixecPc5vsaxVa7HQ LPVZA+2y3qh+PKs5fc8fsEisL0iTqCoCchhmHU4nC6oYEpl9hvItrne7Q Y=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: 38anpzmgEYm8RC8Iis3iaGr6eVYc2bd8LxVkaIVgGeoD/pNFjIQR4yS69KRxzhioTeAC5+4gS/ Hj5zYoImDN9l6+1npPaVAYxtu04FVAcHGByMckRUTwSNzpdyrxz6t80SAe30pofSha9SFCcyKE 0jtzlsBrDbgeQ0nNPxJPXL+/3qWXp2T78oxyk4rNY95oTIY+Oi56b1fAEEpr7kEAh6U1zyZLUu ubLKDYmSOENgXHcdi/E3AoUasW9oest8gKslDov1b9nDZwZ0L4V5ALvVPnn2zRpVyNqUuIZ9d0 +pU= X-SBRS: 5.1 X-MesageID: 35435267 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.79,350,1602561600"; d="scan'208";a="35435267" From: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= To: CC: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= , "Christian Lindig" , David Scott , "Ian Jackson" , Wei Liu Subject: [PATCH v1 1/4] tools/ocaml/libs/xb: do not crash after xenbus is unmapped Date: Fri, 15 Jan 2021 22:29:06 +0000 Message-ID: <0af9839d3a8f27421b4c8f1220f9a2165d815ac2.1610748224.git.edvin.torok@citrix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 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 --- 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 #include +#include #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);