From patchwork Fri Feb 26 14:41:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norbert Manthey X-Patchwork-Id: 12106769 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=-18.8 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, 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 9D70DC433E6 for ; Fri, 26 Feb 2021 14:42:35 +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 312F664E28 for ; Fri, 26 Feb 2021 14:42:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 312F664E28 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de 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.90351.170956 (Exim 4.92) (envelope-from ) id 1lFeK1-0003E5-TA; Fri, 26 Feb 2021 14:42:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 90351.170956; Fri, 26 Feb 2021 14:42:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeK1-0003Dx-Px; Fri, 26 Feb 2021 14:42:25 +0000 Received: by outflank-mailman (input) for mailman id 90351; Fri, 26 Feb 2021 14:42:24 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeJz-0003Af-Vl for xen-devel@lists.xenproject.org; Fri, 26 Feb 2021 14:42:24 +0000 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id fd023e65-989c-4b31-9181-f9799691722c; Fri, 26 Feb 2021 14:42:18 +0000 (UTC) Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2a-1c1b5cdd.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 26 Feb 2021 14:42:11 +0000 Received: from EX13D37EUB004.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-2a-1c1b5cdd.us-west-2.amazon.com (Postfix) with ESMTPS id 3C548A180F; Fri, 26 Feb 2021 14:42:10 +0000 (UTC) Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D37EUB004.ant.amazon.com (10.43.166.187) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 26 Feb 2021 14:42:08 +0000 Received: from u6fc700a6f3c650.ant.amazon.com (10.1.212.27) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 26 Feb 2021 14:42:06 +0000 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 Sender: "Xen-devel" X-Inumbo-ID: fd023e65-989c-4b31-9181-f9799691722c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1614350539; x=1645886539; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=sj+epzrMKHexT+eQInL0yberMRcZJMZtWGnBvr9EvEc=; b=jgPmjlxNqlt0FICNlzHrJi1Dedm5zhk1r+Ikn0QU1H8+OXQ1Fbc7y/tO u0ULtomnF746ELbdc3fieIU+tsZNiQog/UclJa3MsRRu209ka4AEj8Kyr /fejyC+PyxnKaUwwBYH69DS2lrmPe2gmDzuSGXEPpU236Nu8aqeHC4IHJ E=; X-IronPort-AV: E=Sophos;i="5.81,208,1610409600"; d="scan'208";a="91300593" From: Norbert Manthey To: CC: Ian Jackson , Juergen Gross , Wei Liu , Julien Grall , Michael Kurth , Norbert Manthey Subject: [PATCH XENSTORE v1 01/10] xenstore: add missing NULL check Date: Fri, 26 Feb 2021 15:41:35 +0100 Message-ID: <20210226144144.9252-2-nmanthey@amazon.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210226144144.9252-1-nmanthey@amazon.de> References: <20210226144144.9252-1-nmanthey@amazon.de> MIME-Version: 1.0 Precedence: Bulk In case of allocation error, we should not dereference the obtained NULL pointer. Hence, fail early. This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Signed-off-by: Norbert Manthey Reviewed-by: Thomas Friebel Reviewed-by: Julien Grall Reviewed-by: Juergen Gross --- tools/xenstore/xenstored_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -1818,6 +1818,10 @@ static int check_store_(const char *name, struct hashtable *reachable) struct hashtable * children = create_hashtable(16, hash_from_key_fn, keys_equal_fn); + if (!children) { + log("check_store create table: ENOMEM"); + return ENOMEM; + } if (!remember_string(reachable, name)) { hashtable_destroy(children, 0); From patchwork Fri Feb 26 14:41:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norbert Manthey X-Patchwork-Id: 12106771 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=-18.8 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, 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 9D6E1C433DB for ; Fri, 26 Feb 2021 14:42:35 +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 3134564EDB for ; Fri, 26 Feb 2021 14:42:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3134564EDB Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de 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.90350.170944 (Exim 4.92) (envelope-from ) id 1lFeJw-0003B7-LT; Fri, 26 Feb 2021 14:42:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 90350.170944; Fri, 26 Feb 2021 14:42:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeJw-0003B0-Hk; Fri, 26 Feb 2021 14:42:20 +0000 Received: by outflank-mailman (input) for mailman id 90350; Fri, 26 Feb 2021 14:42:19 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeJv-0003Af-6K for xen-devel@lists.xenproject.org; Fri, 26 Feb 2021 14:42:19 +0000 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 544f7879-e262-4601-8e9d-32a2530603a7; Fri, 26 Feb 2021 14:42:18 +0000 (UTC) Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2b-4e24fd92.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 26 Feb 2021 14:42:15 +0000 Received: from EX13D37EUA004.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-2b-4e24fd92.us-west-2.amazon.com (Postfix) with ESMTPS id A0F63A245E; Fri, 26 Feb 2021 14:42:13 +0000 (UTC) Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D37EUA004.ant.amazon.com (10.43.165.124) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 26 Feb 2021 14:42:11 +0000 Received: from u6fc700a6f3c650.ant.amazon.com (10.1.212.27) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 26 Feb 2021 14:42:09 +0000 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 Sender: "Xen-devel" X-Inumbo-ID: 544f7879-e262-4601-8e9d-32a2530603a7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1614350538; x=1645886538; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=z/DnOJlIa9cXjD7A0d8As04PDDD4dbiymrcM3U2q7us=; b=Xe+NLs7N90CvzPGfZD8LqZo0L0ttXEi1LaXREJgMw7QtYBvvAwR80Nlp dRH8DetfBcXHcyW650gqM0Nt1Qeo3KnbeZ3zavde2RFD7e+tyQtTTfQfe zOZT6/E5EjcHvnKuQG86Zyt0blWN+DT+gOe0SaQhV/wkvJF50yoOFIaV4 E=; X-IronPort-AV: E=Sophos;i="5.81,208,1610409600"; d="scan'208";a="91300630" From: Norbert Manthey To: CC: Ian Jackson , Juergen Gross , Wei Liu , Julien Grall , Michael Kurth , Norbert Manthey Subject: [PATCH XENSTORE v1 02/10] xenstore: fix print format string Date: Fri, 26 Feb 2021 15:41:36 +0100 Message-ID: <20210226144144.9252-3-nmanthey@amazon.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210226144144.9252-1-nmanthey@amazon.de> References: <20210226144144.9252-1-nmanthey@amazon.de> MIME-Version: 1.0 Precedence: Bulk Use the correct format specifier for unsigned values. Additionally, a cast was dropped, as the format specifier did not require it anymore. This was reported by analysis with cppcheck. Signed-off-by: Norbert Manthey Reviewed-by: Thomas Friebel Reviewed-by: Julien Grall Reviewed-by: Juergen Gross --- tools/xenstore/xs_tdb_dump.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/xenstore/xs_tdb_dump.c b/tools/xenstore/xs_tdb_dump.c --- a/tools/xenstore/xs_tdb_dump.c +++ b/tools/xenstore/xs_tdb_dump.c @@ -59,8 +59,8 @@ int main(int argc, char *argv[]) fprintf(stderr, "%.*s: BAD truncated\n", (int)key.dsize, key.dptr); else if (data.dsize != total_size(hdr)) - fprintf(stderr, "%.*s: BAD length %i for %i/%i/%i (%i)\n", - (int)key.dsize, key.dptr, (int)data.dsize, + fprintf(stderr, "%.*s: BAD length %zu for %u/%u/%u (%u)\n", + (int)key.dsize, key.dptr, data.dsize, hdr->num_perms, hdr->datalen, hdr->childlen, total_size(hdr)); else { @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) printf("%.*s: ", (int)key.dsize, key.dptr); for (i = 0; i < hdr->num_perms; i++) - printf("%s%c%i", + printf("%s%c%u", i == 0 ? "" : ",", perm_to_char(hdr->perms[i].perms), hdr->perms[i].id); From patchwork Fri Feb 26 14:41:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norbert Manthey X-Patchwork-Id: 12106775 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=-18.8 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, 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 71FE7C433E0 for ; Fri, 26 Feb 2021 14:42:40 +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 0F77A64E28 for ; Fri, 26 Feb 2021 14:42:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F77A64E28 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de 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.90352.170968 (Exim 4.92) (envelope-from ) id 1lFeK7-0003Ib-71; Fri, 26 Feb 2021 14:42:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 90352.170968; Fri, 26 Feb 2021 14:42:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeK7-0003IU-2D; Fri, 26 Feb 2021 14:42:31 +0000 Received: by outflank-mailman (input) for mailman id 90352; Fri, 26 Feb 2021 14:42:29 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeK4-0003Af-W5 for xen-devel@lists.xenproject.org; Fri, 26 Feb 2021 14:42:29 +0000 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4c304731-8eb6-43a7-9e85-74d2e28eb149; Fri, 26 Feb 2021 14:42:19 +0000 (UTC) Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2a-e7be2041.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 26 Feb 2021 14:42:18 +0000 Received: from EX13D37EUB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-2a-e7be2041.us-west-2.amazon.com (Postfix) with ESMTPS id 75A1AA2428; Fri, 26 Feb 2021 14:42:17 +0000 (UTC) Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D37EUB001.ant.amazon.com (10.43.166.31) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 26 Feb 2021 14:42:15 +0000 Received: from u6fc700a6f3c650.ant.amazon.com (10.1.212.27) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 26 Feb 2021 14:42:13 +0000 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 Sender: "Xen-devel" X-Inumbo-ID: 4c304731-8eb6-43a7-9e85-74d2e28eb149 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1614350539; x=1645886539; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=a4CF3aP7V8BLgQT8wGjqFYA8omaY5bulrWv/CPPvqmk=; b=unrra1cdH1zvPCzI6P0P2cMWPp73xYGqhDhfSN50qex9j4IFOCS0Lwi6 7ROdkwS8YMYBO0yFlQ5lb/VgLu9FyCQwWOwP+HCeEQbOchSbmDa/wb6V0 aigyb4u0o3N9p8123l9AumFW14+gtPwbn1DjRhuPhKUfMRa4UPaEyT1Y0 4=; X-IronPort-AV: E=Sophos;i="5.81,208,1610409600"; d="scan'208";a="91300657" From: Norbert Manthey To: CC: Ian Jackson , Juergen Gross , Wei Liu , Julien Grall , Michael Kurth , Norbert Manthey Subject: [PATCH XENSTORE v1 03/10] xenstore: check formats of trace Date: Fri, 26 Feb 2021 15:41:37 +0100 Message-ID: <20210226144144.9252-4-nmanthey@amazon.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210226144144.9252-1-nmanthey@amazon.de> References: <20210226144144.9252-1-nmanthey@amazon.de> MIME-Version: 1.0 Precedence: Bulk When passing format strings to the trace function, allow gcc to analyze those and warn on issues. Signed-off-by: Norbert Manthey Reviewed-by: Thomas Friebel Reviewed-by: Julien Grall Reviewed-by: Juergen Gross --- tools/xenstore/xenstored_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -217,7 +217,7 @@ int delay_request(struct connection *conn, struct buffered_data *in, /* Tracing infrastructure. */ void trace_create(const void *data, const char *type); void trace_destroy(const void *data, const char *type); -void trace(const char *fmt, ...); +void trace(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); void dtrace_io(const struct connection *conn, const struct buffered_data *data, int out); void reopen_log(void); void close_log(void); From patchwork Fri Feb 26 14:41:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norbert Manthey X-Patchwork-Id: 12106777 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=-18.8 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, 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 7247FC433E6 for ; Fri, 26 Feb 2021 14:42:40 +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 0F7BD64EDB for ; Fri, 26 Feb 2021 14:42:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F7BD64EDB Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de 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.90353.170974 (Exim 4.92) (envelope-from ) id 1lFeK7-0003JN-KZ; Fri, 26 Feb 2021 14:42:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 90353.170974; Fri, 26 Feb 2021 14:42:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeK7-0003JA-CY; Fri, 26 Feb 2021 14:42:31 +0000 Received: by outflank-mailman (input) for mailman id 90353; Fri, 26 Feb 2021 14:42:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeK5-0003Hj-Sq for xen-devel@lists.xenproject.org; Fri, 26 Feb 2021 14:42:29 +0000 Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2b51fa24-5831-4103-8c14-4e9df781b30f; Fri, 26 Feb 2021 14:42:29 +0000 (UTC) Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2c-2225282c.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 26 Feb 2021 14:42:22 +0000 Received: from EX13D37EUA002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2c-2225282c.us-west-2.amazon.com (Postfix) with ESMTPS id 1A2F2A07DC; Fri, 26 Feb 2021 14:42:21 +0000 (UTC) Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D37EUA002.ant.amazon.com (10.43.165.200) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 26 Feb 2021 14:42:19 +0000 Received: from u6fc700a6f3c650.ant.amazon.com (10.1.212.27) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 26 Feb 2021 14:42:17 +0000 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 Sender: "Xen-devel" X-Inumbo-ID: 2b51fa24-5831-4103-8c14-4e9df781b30f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1614350549; x=1645886549; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ufqPi5XZ73oaK8Z3Lj+n3A5UsFVL/yuIxs1VZVOClrA=; b=ej8KE68Muqi19IZucueYR8pAS6Ex1Aq9/uUtE3nzc5gd2ez1E1IGB4VZ EvYgeEH067YjdNl4pwCP4MCVfVX54UcU0qAHjsoJYPiyTuMR6TySJYmQB hYLIoKvleBGeC35Otj9kz9nsmCE1X57cgXMv/wYZtKCNDwQ5zueEShrQf c=; X-IronPort-AV: E=Sophos;i="5.81,208,1610409600"; d="scan'208";a="92741411" From: Norbert Manthey To: CC: Ian Jackson , Juergen Gross , Wei Liu , Julien Grall , Michael Kurth , Norbert Manthey Subject: [PATCH XENSTORE v1 04/10] xenstore_client: handle memory on error Date: Fri, 26 Feb 2021 15:41:38 +0100 Message-ID: <20210226144144.9252-5-nmanthey@amazon.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210226144144.9252-1-nmanthey@amazon.de> References: <20210226144144.9252-1-nmanthey@amazon.de> MIME-Version: 1.0 Precedence: Bulk In case a command fails, also free the memory. As this is for the CLI client, currently the leaked memory is freed right after receiving the error, as the application terminates next. Similarly, if the allocation fails, do not use the NULL pointer afterwards, but instead error out. This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Signed-off-by: Norbert Manthey Reviewed-by: Thomas Friebel Reviewed-by: Julien Grall Reviewed-by: Juergen Gross --- tools/xenstore/xenstore_client.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/xenstore/xenstore_client.c b/tools/xenstore/xenstore_client.c --- a/tools/xenstore/xenstore_client.c +++ b/tools/xenstore/xenstore_client.c @@ -382,11 +382,14 @@ perform(enum mode mode, int optind, int argc, char **argv, struct xs_handle *xsh /* Copy path, because we can't modify argv because we will need it again if xs_transaction_end gives us EAGAIN. */ char *p = malloc(strlen(path) + 1); + if (!p) + return 1; strcpy(p, path); path = p; again: if (do_rm(path, xsh, xth)) { + free(path); return 1; } From patchwork Fri Feb 26 14:41:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norbert Manthey X-Patchwork-Id: 12106779 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=-18.8 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, 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 9C8DCC433E0 for ; Fri, 26 Feb 2021 14:42:42 +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 4823864E20 for ; Fri, 26 Feb 2021 14:42:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4823864E20 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de 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.90354.170992 (Exim 4.92) (envelope-from ) id 1lFeKB-0003PZ-VZ; Fri, 26 Feb 2021 14:42:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 90354.170992; Fri, 26 Feb 2021 14:42:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeKB-0003PN-R8; Fri, 26 Feb 2021 14:42:35 +0000 Received: by outflank-mailman (input) for mailman id 90354; Fri, 26 Feb 2021 14:42:34 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeK9-0003Af-WF for xen-devel@lists.xenproject.org; Fri, 26 Feb 2021 14:42:34 +0000 Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2894b2c9-2b51-40ed-9e89-1632ac5f3a26; Fri, 26 Feb 2021 14:42:33 +0000 (UTC) Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-16425a8d.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Feb 2021 14:42:25 +0000 Received: from EX13D02EUB004.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-1d-16425a8d.us-east-1.amazon.com (Postfix) with ESMTPS id 12398100C47; Fri, 26 Feb 2021 14:42:24 +0000 (UTC) Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D02EUB004.ant.amazon.com (10.43.166.221) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 26 Feb 2021 14:42:22 +0000 Received: from u6fc700a6f3c650.ant.amazon.com (10.1.212.27) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 26 Feb 2021 14:42:20 +0000 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 Sender: "Xen-devel" X-Inumbo-ID: 2894b2c9-2b51-40ed-9e89-1632ac5f3a26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1614350553; x=1645886553; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=aupOUlFlXdRu4KMtyn+0J4vkXjNtTUzjaeSxjmikpeI=; b=GlBHrEWZnEBl7CZdRlCi/dpGEnXRCr3W49Sr1Q+fcVKrwc3SiVTmdbqs 8sBRbLbYPYv5VbC11GhmEhLN/0NKTHrnlp+FcFc5UxzUXJzWjX4rbWwKw yzsHP60SQ0dOKc1lP59qbFv4IMRU8qSd9QMQVC6BKZtshvLqowTz1Lclh 8=; X-IronPort-AV: E=Sophos;i="5.81,208,1610409600"; d="scan'208";a="88504713" From: Norbert Manthey To: CC: Ian Jackson , Juergen Gross , Wei Liu , Julien Grall , Michael Kurth , Norbert Manthey Subject: [PATCH XENSTORE v1 05/10] xenstore: handle daemon creation errors Date: Fri, 26 Feb 2021 15:41:39 +0100 Message-ID: <20210226144144.9252-6-nmanthey@amazon.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210226144144.9252-1-nmanthey@amazon.de> References: <20210226144144.9252-1-nmanthey@amazon.de> MIME-Version: 1.0 Precedence: Bulk In rare cases, the path to the daemon socket cannot be created as it is longer than PATH_MAX. Instead of failing with a NULL pointer dereference, terminate the application with an error message. This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Signed-off-by: Norbert Manthey Reviewed-by: Thomas Friebel Reviewed-by: Julien Grall Reviewed-by: Juergen Gross --- tools/xenstore/xenstored_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -1996,6 +1996,9 @@ static void init_sockets(void) struct sockaddr_un addr; const char *soc_str = xs_daemon_socket(); + if (!soc_str) + barf_perror("Failed to obtain xs domain socket"); + /* Create sockets for them to listen to. */ atexit(destroy_fds); sock = socket(PF_UNIX, SOCK_STREAM, 0); From patchwork Fri Feb 26 14:41:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norbert Manthey X-Patchwork-Id: 12106781 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=-18.8 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, 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 AFC81C433DB for ; Fri, 26 Feb 2021 14:42:47 +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 4DC6E64E28 for ; Fri, 26 Feb 2021 14:42:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4DC6E64E28 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de 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.90355.171004 (Exim 4.92) (envelope-from ) id 1lFeKG-0003VA-Ep; Fri, 26 Feb 2021 14:42:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 90355.171004; Fri, 26 Feb 2021 14:42:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeKG-0003Ux-Af; Fri, 26 Feb 2021 14:42:40 +0000 Received: by outflank-mailman (input) for mailman id 90355; Fri, 26 Feb 2021 14:42:39 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeKF-0003Af-0i for xen-devel@lists.xenproject.org; Fri, 26 Feb 2021 14:42:39 +0000 Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f72aee7e-87fb-4250-a417-5e8e4e12b4e6; Fri, 26 Feb 2021 14:42:35 +0000 (UTC) Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2c-579b7f5b.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Feb 2021 14:42:35 +0000 Received: from EX13D02EUB003.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2c-579b7f5b.us-west-2.amazon.com (Postfix) with ESMTPS id 5220AA15CF; Fri, 26 Feb 2021 14:42:34 +0000 (UTC) Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D02EUB003.ant.amazon.com (10.43.166.172) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 26 Feb 2021 14:42:32 +0000 Received: from u6fc700a6f3c650.ant.amazon.com (10.1.212.27) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 26 Feb 2021 14:42:23 +0000 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 Sender: "Xen-devel" X-Inumbo-ID: f72aee7e-87fb-4250-a417-5e8e4e12b4e6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1614350555; x=1645886555; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=vbgIE8H3XZ85DmgU6vJvOMOFjDGWkhUCPA58yeFxSQY=; b=UP2scPgBu89tj4LtgnzPw/7OVOsUe84+39oH/hPuS7V5B6rEWmtIXNtl 7kGsVAfPKE6KPNdpqt9yIjzO+za0Zx6zvvDgZjIXiwDdbTZHCzDEVFU8D Mf39rjqw4HbxJo5FuJXhEBdmZSEoW9ii9kUgq8tBGNl+WCgKMC4uBkN2j U=; X-IronPort-AV: E=Sophos;i="5.81,208,1610409600"; d="scan'208";a="88504759" From: Norbert Manthey To: CC: Ian Jackson , Juergen Gross , Wei Liu , Julien Grall , Michael Kurth , Norbert Manthey Subject: [PATCH XENSTORE v1 06/10] xenstored: handle port reads correctly Date: Fri, 26 Feb 2021 15:41:40 +0100 Message-ID: <20210226144144.9252-7-nmanthey@amazon.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210226144144.9252-1-nmanthey@amazon.de> References: <20210226144144.9252-1-nmanthey@amazon.de> MIME-Version: 1.0 Precedence: Bulk The read value could be larger than a signed 32bit integer. As -1 is used as error value, we should not rely on using the full 32 bits. Hence, when reading the port number, we should make sure we only return valid values. This change sanity checks the input. The issue is that the value for the port is 1. transmitted as a string, with a fixed amount of digits. 2. Next, this string is parsed by a function that can deal with strings representing 64bit integers 3. A 64bit integer is returned, and will be truncated to it's lower 32bits, resulting in a wrong port number (in case the sender of the string decides to craft a suitable 64bit value). The value is typically provided by the kernel, which has this value hard coded in the proper range. As we use the function strtoul, non-digit character are considered as end of the input, and hence do not require checking. Therefore, this change only covers the corner case to make sure we stay in the 32 bit range. This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Signed-off-by: Norbert Manthey Reviewed-by: Thomas Friebel Reviewed-by: Julien Grall --- tools/xenstore/xenstored_posix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/xenstore/xenstored_posix.c b/tools/xenstore/xenstored_posix.c --- a/tools/xenstore/xenstored_posix.c +++ b/tools/xenstore/xenstored_posix.c @@ -116,7 +116,7 @@ evtchn_port_t xenbus_evtchn(void) { int fd; int rc; - evtchn_port_t port; + uint64_t port; char str[20]; fd = open(XENSTORED_PORT_DEV, O_RDONLY); @@ -136,6 +136,10 @@ evtchn_port_t xenbus_evtchn(void) port = strtoul(str, NULL, 0); close(fd); + + if (port >= UINT32_MAX) + return -1; + return port; } From patchwork Fri Feb 26 14:41:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norbert Manthey X-Patchwork-Id: 12106783 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=-18.8 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, 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 8E83CC433DB for ; Fri, 26 Feb 2021 14:42: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 368F664EDB for ; Fri, 26 Feb 2021 14:42:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 368F664EDB Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de 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.90357.171016 (Exim 4.92) (envelope-from ) id 1lFeKL-0003bm-PR; Fri, 26 Feb 2021 14:42:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 90357.171016; Fri, 26 Feb 2021 14:42:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeKL-0003bb-LP; Fri, 26 Feb 2021 14:42:45 +0000 Received: by outflank-mailman (input) for mailman id 90357; Fri, 26 Feb 2021 14:42:44 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeKK-0003Af-0e for xen-devel@lists.xenproject.org; Fri, 26 Feb 2021 14:42:44 +0000 Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 332821f5-e44f-486c-9617-573c982777f0; Fri, 26 Feb 2021 14:42:42 +0000 (UTC) Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2a-1c1b5cdd.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 26 Feb 2021 14:42:42 +0000 Received: from EX13D02EUB003.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-2a-1c1b5cdd.us-west-2.amazon.com (Postfix) with ESMTPS id 4D6FEA17CD; Fri, 26 Feb 2021 14:42:41 +0000 (UTC) Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D02EUB003.ant.amazon.com (10.43.166.172) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 26 Feb 2021 14:42:39 +0000 Received: from u6fc700a6f3c650.ant.amazon.com (10.1.212.27) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 26 Feb 2021 14:42:37 +0000 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 Sender: "Xen-devel" X-Inumbo-ID: 332821f5-e44f-486c-9617-573c982777f0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1614350562; x=1645886562; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=waHFe5N5zD0cDJXNQ231nyWcAqRV9zOpFqGCBH9GqNQ=; b=qldJzvdj2I8bgEtNmUiBlNlXySANiaIgWRBf7zMTb8fVaV6EwaaB4bzK s/d2RASTOM5yGZ2RVD5+W36P5rjyzowJEIbApRjO2JfVVMnotjyrU3OPK H+OeJPsMYpCF2f+aMYlvqtT9XBbvrPiBQVXP6O7SoQwPBBu6Vlyg3vNQL c=; X-IronPort-AV: E=Sophos;i="5.81,208,1610409600"; d="scan'208";a="92741519" From: Norbert Manthey To: CC: Ian Jackson , Juergen Gross , Wei Liu , Julien Grall , Michael Kurth , Norbert Manthey Subject: [PATCH XENSTORE v1 07/10] xenstore: handle do_mkdir and do_rm failure Date: Fri, 26 Feb 2021 15:41:41 +0100 Message-ID: <20210226144144.9252-8-nmanthey@amazon.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210226144144.9252-1-nmanthey@amazon.de> References: <20210226144144.9252-1-nmanthey@amazon.de> MIME-Version: 1.0 Precedence: Bulk In the out of memory case, we might return a NULL pointer when canonicalizing node names. This NULL pointer is not checked when creating a directory, or when removing a node. This change handles the NULL pointer for these two cases. This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Signed-off-by: Norbert Manthey Reviewed-by: Thomas Friebel Reviewed-by: Julien Grall Reviewed-by: Juergen Gross --- tools/xenstore/xenstored_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -1160,6 +1160,8 @@ static int do_mkdir(struct connection *conn, struct buffered_data *in) /* No permissions? */ if (errno != ENOENT) return errno; + if (!name) + return ENOMEM; node = create_node(conn, in, name, NULL, 0); if (!node) return errno; @@ -1274,6 +1276,8 @@ static int do_rm(struct connection *conn, struct buffered_data *in) if (!node) { /* Didn't exist already? Fine, if parent exists. */ if (errno == ENOENT) { + if (!name) + return ENOMEM; parentname = get_parent(in, name); if (!parentname) return errno; From patchwork Fri Feb 26 14:41:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norbert Manthey X-Patchwork-Id: 12106785 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=-18.8 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, 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 6E5C6C433E6 for ; Fri, 26 Feb 2021 14:43:02 +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 1CEED64EDB for ; Fri, 26 Feb 2021 14:43:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CEED64EDB Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de 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.90362.171028 (Exim 4.92) (envelope-from ) id 1lFeKV-0003lw-5s; Fri, 26 Feb 2021 14:42:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 90362.171028; Fri, 26 Feb 2021 14:42:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeKV-0003lo-07; Fri, 26 Feb 2021 14:42:55 +0000 Received: by outflank-mailman (input) for mailman id 90362; Fri, 26 Feb 2021 14:42:54 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeKU-0003Af-1D for xen-devel@lists.xenproject.org; Fri, 26 Feb 2021 14:42:54 +0000 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b9e2aa11-92ed-4c6f-b463-3924e0fdbdee; Fri, 26 Feb 2021 14:42:47 +0000 (UTC) Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2b-c7131dcf.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 26 Feb 2021 14:42:46 +0000 Received: from EX13D02EUB002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-2b-c7131dcf.us-west-2.amazon.com (Postfix) with ESMTPS id 254A4A1D59; Fri, 26 Feb 2021 14:42:45 +0000 (UTC) Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D02EUB002.ant.amazon.com (10.43.166.170) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 26 Feb 2021 14:42:43 +0000 Received: from u6fc700a6f3c650.ant.amazon.com (10.1.212.27) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 26 Feb 2021 14:42:40 +0000 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 Sender: "Xen-devel" X-Inumbo-ID: b9e2aa11-92ed-4c6f-b463-3924e0fdbdee DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1614350568; x=1645886568; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=INzRJ60EoL7cehlQhV+bX6hPIdepzG7ggFncfF3yBWA=; b=Q2MvJYJ6F2Rgl/e/N4BzVypB4Rm1SE1WMv+cTc39BxFizlRpfAtIAUKq tnR+ktRY2QBXgH6valgWP/gTOQHG4EYeIcP2QoQ+rNg/+XKesGiBNdmas OQWFgG0hc7fvHlYv4mQqvJ2CT00qHaqr+h/RBtJezb9Ch2ngWChJEP9th 8=; X-IronPort-AV: E=Sophos;i="5.81,208,1610409600"; d="scan'208";a="88628276" From: Norbert Manthey To: CC: Ian Jackson , Juergen Gross , Wei Liu , Julien Grall , Michael Kurth , Michael Kurth , Norbert Manthey Subject: [PATCH XENSTORE v1 08/10] xenstore: add missing NULL check Date: Fri, 26 Feb 2021 15:41:42 +0100 Message-ID: <20210226144144.9252-9-nmanthey@amazon.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210226144144.9252-1-nmanthey@amazon.de> References: <20210226144144.9252-1-nmanthey@amazon.de> MIME-Version: 1.0 Precedence: Bulk From: Michael Kurth In case of allocation error, we should not dereference the obtained NULL pointer. This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Signed-off-by: Michael Kurth Signed-off-by: Norbert Manthey Reviewed-by: Thomas Friebel Reviewed-by: Julien Grall Reviewed-by: Juergen Gross --- tools/xenstore/xenstored_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -504,6 +504,11 @@ int write_node_raw(struct connection *conn, TDB_DATA *key, struct node *node, } data.dptr = talloc_size(node, data.dsize); + if (!data.dptr) { + errno = ENOMEM; + return errno; + } + hdr = (void *)data.dptr; hdr->generation = node->generation; hdr->num_perms = node->perms.num; From patchwork Fri Feb 26 14:41:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norbert Manthey X-Patchwork-Id: 12106787 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=-18.8 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, 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 36B93C433E0 for ; Fri, 26 Feb 2021 14:43:07 +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 D71C464E20 for ; Fri, 26 Feb 2021 14:43:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D71C464E20 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de 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.90364.171040 (Exim 4.92) (envelope-from ) id 1lFeKa-0003qp-Dt; Fri, 26 Feb 2021 14:43:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 90364.171040; Fri, 26 Feb 2021 14:43:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeKa-0003qf-Ab; Fri, 26 Feb 2021 14:43:00 +0000 Received: by outflank-mailman (input) for mailman id 90364; Fri, 26 Feb 2021 14:42:59 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeKZ-0003Af-18 for xen-devel@lists.xenproject.org; Fri, 26 Feb 2021 14:42:59 +0000 Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ad3255a7-ceb8-4214-be52-043c296c2896; Fri, 26 Feb 2021 14:42:50 +0000 (UTC) Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2b-c7131dcf.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 26 Feb 2021 14:42:49 +0000 Received: from EX13D37EUB002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-2b-c7131dcf.us-west-2.amazon.com (Postfix) with ESMTPS id EFEB6A21B1; Fri, 26 Feb 2021 14:42:48 +0000 (UTC) Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D37EUB002.ant.amazon.com (10.43.166.116) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 26 Feb 2021 14:42:47 +0000 Received: from u6fc700a6f3c650.ant.amazon.com (10.1.212.27) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 26 Feb 2021 14:42:44 +0000 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 Sender: "Xen-devel" X-Inumbo-ID: ad3255a7-ceb8-4214-be52-043c296c2896 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1614350570; x=1645886570; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=PoZZTY1JhoFNyUyWnPJ+qOgbzP4vOc+deh5S5ccFoAU=; b=al+WrVrFP/kMmEXS4N8LI45roAMxWvIcXsaBwsmFjrjToHum7nK8uxO8 7dPrZL1kfZkokl91OxBa7ts8XldulN7HkFzpxau+rDuKrcjAvkkILoNKJ gGlttY6/iKAcJlgFUMZicPgtyJ+UEiohRTlWJc+5zmbg2sef18GYV88Nn c=; X-IronPort-AV: E=Sophos;i="5.81,208,1610409600"; d="scan'208";a="92741617" From: Norbert Manthey To: CC: Ian Jackson , Juergen Gross , Wei Liu , Julien Grall , Michael Kurth , Norbert Manthey Subject: [PATCH XENSTORE v1 09/10] xs: handle daemon socket error Date: Fri, 26 Feb 2021 15:41:43 +0100 Message-ID: <20210226144144.9252-10-nmanthey@amazon.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210226144144.9252-1-nmanthey@amazon.de> References: <20210226144144.9252-1-nmanthey@amazon.de> MIME-Version: 1.0 Precedence: Bulk When starting the daemon, we might see a NULL pointer instead of the path to the socket. Only relevant in case we start the process in a very deep directory path, with a length close to 4096 so that appending "/socket" would exceed the limit. Hence, such an error is unlikely, but should still be fixed to not result in a NULL pointer dereference. This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Signed-off-by: Norbert Manthey Reviewed-by: Thomas Friebel Reviewed-by: Julien Grall Reviewed-by: Juergen Gross --- tools/libs/store/xs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c --- a/tools/libs/store/xs.c +++ b/tools/libs/store/xs.c @@ -240,6 +240,9 @@ static struct xs_handle *get_handle(const char *connect_to) struct xs_handle *h = NULL; int saved_errno; + if (!connect_to) + return NULL; + h = malloc(sizeof(*h)); if (h == NULL) goto err; From patchwork Fri Feb 26 14:41:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Norbert Manthey X-Patchwork-Id: 12106791 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=-18.8 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, 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 E7984C433E0 for ; Fri, 26 Feb 2021 14:49:15 +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 AB07064E28 for ; Fri, 26 Feb 2021 14:49:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB07064E28 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de 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.90380.171051 (Exim 4.92) (envelope-from ) id 1lFeQT-0004XF-49; Fri, 26 Feb 2021 14:49:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 90380.171051; Fri, 26 Feb 2021 14:49:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeQT-0004X8-13; Fri, 26 Feb 2021 14:49:05 +0000 Received: by outflank-mailman (input) for mailman id 90380; Fri, 26 Feb 2021 14:49:04 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lFeKj-0003Af-1T for xen-devel@lists.xenproject.org; Fri, 26 Feb 2021 14:43:09 +0000 Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 44022063-d5f2-4039-a073-964d796716bb; Fri, 26 Feb 2021 14:42:54 +0000 (UTC) Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2a-c5104f52.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 26 Feb 2021 14:42:54 +0000 Received: from EX13D02EUB002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2a-c5104f52.us-west-2.amazon.com (Postfix) with ESMTPS id 27771A1E6A; Fri, 26 Feb 2021 14:42:53 +0000 (UTC) Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX13D02EUB002.ant.amazon.com (10.43.166.170) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 26 Feb 2021 14:42:51 +0000 Received: from u6fc700a6f3c650.ant.amazon.com (10.1.212.27) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 26 Feb 2021 14:42:49 +0000 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 Sender: "Xen-devel" X-Inumbo-ID: 44022063-d5f2-4039-a073-964d796716bb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1614350575; x=1645886575; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=/ouoVhSElmsKf09bjsubId7QzwGwRxcvcchsYXzRAAQ=; b=ChvSllwggXCJgCv3PB5U54Aw4kKAv3fd8lbIrNiKsIl2bdAKO74kNeJx d5q1g9YmxdKOoZ9DLR9nnP6XVDsX9tIzGlcTXFhz27bzCUi1kkJ8tgVQl GGTz0il6TIHXeBaEMB+pRneCnCQsTCWF2ZPu9wYuMc08myGZJ33lIg2Ui E=; X-IronPort-AV: E=Sophos;i="5.81,208,1610409600"; d="scan'208";a="88504949" From: Norbert Manthey To: CC: Ian Jackson , Juergen Gross , Wei Liu , Julien Grall , Michael Kurth , Norbert Manthey Subject: [PATCH XENSTORE v1 10/10] xs: add error handling Date: Fri, 26 Feb 2021 15:41:44 +0100 Message-ID: <20210226144144.9252-11-nmanthey@amazon.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210226144144.9252-1-nmanthey@amazon.de> References: <20210226144144.9252-1-nmanthey@amazon.de> MIME-Version: 1.0 Precedence: Bulk In case of a failure deep in the call tree, we might return NULL as the value of the domain. In that case, error out instead of dereferencing the NULL pointer. This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Signed-off-by: Norbert Manthey Reviewed-by: Julien Grall Reviewed-by: Raphael Ning Reviewed-by: Juergen Gross --- tools/libs/store/xs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c --- a/tools/libs/store/xs.c +++ b/tools/libs/store/xs.c @@ -1183,7 +1183,12 @@ bool xs_path_is_subpath(const char *parent, const char *child) bool xs_is_domain_introduced(struct xs_handle *h, unsigned int domid) { char *domain = single_with_domid(h, XS_IS_DOMAIN_INTRODUCED, domid); - int rc = strcmp("F", domain); + bool rc = false; + + if (!domain) + return rc; + + rc = strcmp("F", domain) != 0; free(domain); return rc;