From nobody Fri May 3 14:27:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1614350560; cv=none; d=zohomail.com; s=zohoarc; b=DORpftTRL3a7QovKo8NhyS7ODuBBv2MWJ4zJFSU9QDuZMAh13wXoGFoH2J20SLw9vcuua0MZELP+rFjsVcS7D7vrPii4WuHmNBatnCL6JCIztBQdKl6chtW1Wq9JEV4cb3QqEeuQVAAkyqb/pS/VAZe579NVdZ1pO77+LOovErE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614350560; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sj+epzrMKHexT+eQInL0yberMRcZJMZtWGnBvr9EvEc=; b=d8/tHaYYVimRanYR/ggu7JABYTKE/iQSaRf0gwAN+UV+rMUuacnHxLlmC+Su3ewTlfTQQdKv/Jp1NGP5ZohTz9FWtahUDgiV9zqX1DeuTQQaFg6Hy1nhOM8ZxoN2faVFnfso57bRauw1MyMTFpwzk3olSFK32NF0Hh799hh4zr0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 161435056069853.25449340473574; Fri, 26 Feb 2021 06:42:40 -0800 (PST) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_cor= e.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 has= htable *reachable) =20 struct hashtable * children =3D create_hashtable(16, hash_from_key_fn, keys_equal_fn); + if (!children) { + log("check_store create table: ENOMEM"); + return ENOMEM; + } =20 if (!remember_string(reachable, name)) { hashtable_destroy(children, 0); --=20 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 From nobody Fri May 3 14:27:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1614350562; cv=none; d=zohomail.com; s=zohoarc; b=Vv9cwW6zESV5bpe14dPkf/MSmbglMaq40ACKjfSRg+Cw9BUFBlKBxL/TzAah6ppTvHrikLTnocvAhikaows2QWVgiwwi3zRFYrN5Zf9zdTd2S6kDeTPAKZexK1sVCE7PDVwB3QZ47e9YBLJWaxR5t3yUfkzvH/2Oz2h7XTEtnpI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614350562; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=z/DnOJlIa9cXjD7A0d8As04PDDD4dbiymrcM3U2q7us=; b=dUeXeSmJMTMjmmh+gGzQYoh7FHU4lEqy+0G7HUdyF+ZO87ao2ie+LTbU/QTaqI/kP1l8Bw/HHwr7Y60TP4hTGO6EG1cr/oreHvsE9qwRME1lnAMU+xLmx4Yr0TiMZhyzNh3yIgoA5ZjbX3w3Lt+P3hOBeVmWPTen7LO0YWR4wkM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1614350562157785.1583531524486; Fri, 26 Feb 2021 06:42:42 -0800 (PST) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 !=3D 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[]) =20 printf("%.*s: ", (int)key.dsize, key.dptr); for (i =3D 0; i < hdr->num_perms; i++) - printf("%s%c%i", + printf("%s%c%u", i =3D=3D 0 ? "" : ",", perm_to_char(hdr->perms[i].perms), hdr->perms[i].id); --=20 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 From nobody Fri May 3 14:27:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1614350564; cv=none; d=zohomail.com; s=zohoarc; b=iJ/ld2GuCCv54L4TQa6fZMgWIwOrPwvPjyDp/y20XsZRjDh0qJHi32PSHBZv1sSVKNvHlx8CgRMEKCvV8WkrCvzQbBDf+8rJGO3vuEKUvFcRrL1EUUsILRH7DYcBJMAqlfdqU8sl9RcspqINUsz/8FPZwxhNcJK3uhRJ43G4Kxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614350564; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a4CF3aP7V8BLgQT8wGjqFYA8omaY5bulrWv/CPPvqmk=; b=n6rwoZTwA4tZnXOicqJrW8nZhyPo0W1vA/Yq7VzYwyj1KV1l6C/4qQmSZjdm0rC/KKvH+3KTFiZKfqog8sY1wNhq/nP1Ko67Jyy/Hd+FutWiPhlhINOooJ24tiPujRyjqZYnCTsGjm5DBiHBOA9tVI1FpEJ3gw0zyLEoPY8zf0I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1614350564280142.9287766507731; Fri, 26 Feb 2021 06:42:44 -0800 (PST) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_cor= e.h --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -217,7 +217,7 @@ int delay_request(struct connection *conn, struct buffe= red_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); --=20 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 From nobody Fri May 3 14:27:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1614350564; cv=none; d=zohomail.com; s=zohoarc; b=ECPCxoPPsVBX8Zv0KftOQE5TX/cM/fGdVsVgS4qHVpaGkPNxT/e6CtXPpRq/enk2uR7LtvHiHVtz+/4m6hCDOtn13dUl+v8l+FQs3W7cZT8OOlzB513C6wrylNxQMnrbMdL60LFKpmJZoqf46PxFXm59ns1UJj8RkqfGz7k7LzY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614350564; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ufqPi5XZ73oaK8Z3Lj+n3A5UsFVL/yuIxs1VZVOClrA=; b=UAyKfperfpiacHpVnVKiVY/YUu1O5CWbHx+lp3NDeFibA4Kkhiy3bTfatdYXor6FGGLMll8j1VwH8Sngz30tTYQs05GKiX/sMro3AcdHZy0PVJfX+p6ipLQuEKd1x2yVZVsQIxNSiSdimMX190Yt7POaJ24arRKqPi4YbVZ2p4M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1614350564285662.1084616299984; Fri, 26 Feb 2021 06:42:44 -0800 (PST) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_cli= ent.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 =3D malloc(strlen(path) + 1); + if (!p) + return 1; strcpy(p, path); path =3D p; =20 again: if (do_rm(path, xsh, xth)) { + free(path); return 1; } =20 --=20 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 From nobody Fri May 3 14:27:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1614350568; cv=none; d=zohomail.com; s=zohoarc; b=T4uA7SFuU5d3+pjLUgyYCxsZQzPP1Fqlvmy7bUxXnLWFhqVTcHOB9PedT+AYIFYEgk5cR3sX63C6b4i0eOLwm31UvTXpFUDvzKvFt7kxI7gJwkqvTRzWMZWUQ6E1YUvKnCHQ1IeNiX3Xz2UvV4GO3Q5YUfbUgUtZ/mRZ8INiQXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614350568; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aupOUlFlXdRu4KMtyn+0J4vkXjNtTUzjaeSxjmikpeI=; b=iaL2IMhBdFF2SbPkpaE3pdvOhm/H5J9tpJEuR1wYv7U/0lGwHrDUTGeiuos3hck9AQGTL9+elrWEIdalYizvy4yfpSnZS2AyxA6vSzVCubfUSOzsiL3V6kBxclq6H26oprmj2AFEJ5NHbEhuyAengXDTqdqjCR1LbG9X3aE3csI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1614350568053791.1765212184512; Fri, 26 Feb 2021 06:42:48 -0800 (PST) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_cor= e.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 =3D xs_daemon_socket(); =20 + if (!soc_str) + barf_perror("Failed to obtain xs domain socket"); + /* Create sockets for them to listen to. */ atexit(destroy_fds); sock =3D socket(PF_UNIX, SOCK_STREAM, 0); --=20 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 From nobody Fri May 3 14:27:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1614350571; cv=none; d=zohomail.com; s=zohoarc; b=WuMKDDruoCeWeQJV4BKVrg9hLuPvyLvAIC/eM32/EHvwBd5vbwKh6XPwRuNfBnkt6b2aBPMhxNMIXWRIek4VMaEn2a2Sm0a21+jF6nPOM0QML7ssn4LLL1d4COyS1cOU0lMHaRZ69VLvx49qcwOIeRnvVk8DGFEKscGO4s2RxIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614350571; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vbgIE8H3XZ85DmgU6vJvOMOFjDGWkhUCPA58yeFxSQY=; b=bO98mgSGcVQc6XxLGY7aHZmBOP0F6d0AaBBPc2vkicegg8UDsSZnc0ntCrQmJF7Jdk5FcQzFmNoDz4rYuF0ypfi3wdISqcj9qq8wiWLc7y7RPm/EQPbVz2caE7B+tjOAZgNQjDcy+zir+T7P7DVcfpLZCmg/Mss1JlfbybIdxqk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1614350571505800.5102781389191; Fri, 26 Feb 2021 06:42:51 -0800 (PST) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_po= six.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]; =20 fd =3D open(XENSTORED_PORT_DEV, O_RDONLY); @@ -136,6 +136,10 @@ evtchn_port_t xenbus_evtchn(void) port =3D strtoul(str, NULL, 0); =20 close(fd); + + if (port >=3D UINT32_MAX) + return -1; + return port; } =20 --=20 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 From nobody Fri May 3 14:27:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1614350577; cv=none; d=zohomail.com; s=zohoarc; b=dZdS0TcHvrMeONmIw3Jc8TE0dCxdVFfaKwyBg2koDjmT+uLPuPMKcSqepKmBwR3jZBYE+IptAU6hSSYY6uHiEGlQSIxbNeRKo9pFqLf1aSgMLe49SCCjjXDvgU65v4l4tuIKDw4C6Q23QJFAkVsDew6E+USxoi1lINsb5bl6uOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614350577; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=waHFe5N5zD0cDJXNQ231nyWcAqRV9zOpFqGCBH9GqNQ=; b=B4kIl8dm/qmZW05CIHvhwWJSuOFFZkGSXCk5+aa6JYGD1oE5qjyotmyC1vON0CTeGJ0Y4uXVI2ou7WswZWnm/4t6uUjFnKR7J0v1/rd/HTLB3P0ny2MYIBRKwI3Ru6jLZCTcI6GeLTcp5y05GwkxwWsRtOcFOfrjowjb4gRJMg8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1614350577539428.2160822655311; Fri, 26 Feb 2021 06:42:57 -0800 (PST) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_cor= e.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 b= uffered_data *in) /* No permissions? */ if (errno !=3D ENOENT) return errno; + if (!name) + return ENOMEM; node =3D create_node(conn, in, name, NULL, 0); if (!node) return errno; @@ -1274,6 +1276,8 @@ static int do_rm(struct connection *conn, struct buff= ered_data *in) if (!node) { /* Didn't exist already? Fine, if parent exists. */ if (errno =3D=3D ENOENT) { + if (!name) + return ENOMEM; parentname =3D get_parent(in, name); if (!parentname) return errno; --=20 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 From nobody Fri May 3 14:27:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1614350586; cv=none; d=zohomail.com; s=zohoarc; b=H+UYfY7NgTHcypSZ1pCJh1hlPcPqzClr6Vi4uV3Eh/8WhZJfb3Omz5nEnTYSZQLhkCGNQC+t1ehf1oEgSEEBtKaJCr/htEH8LTh3ojJJxtRK6jYetvpeW/Hwb+yPmuICnL13RWPOVA9fZx6NtHQsXN4HWD25kyDk3BhIgFcuYhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614350586; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=INzRJ60EoL7cehlQhV+bX6hPIdepzG7ggFncfF3yBWA=; b=LRJkVhcPDBBNJ/bYGyls8r/RcQcATkGSl1L2Ne8wk9boetDRzf6DPLG0Pms+aiGYtJnSKnEZeSPUoSXLdTOy1OY5w0qLl5STu37K3IwGBoQ7zxB0bweZbozJ6llABeaOo1FQtrzQo6T5Y8xZAr9dpStY2jnuNRabmC5EhPXj/js= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1614350586565303.6027576610021; Fri, 26 Feb 2021 06:43:06 -0800 (PST) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_cor= e.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, } =20 data.dptr =3D talloc_size(node, data.dsize); + if (!data.dptr) { + errno =3D ENOMEM; + return errno; + } + hdr =3D (void *)data.dptr; hdr->generation =3D node->generation; hdr->num_perms =3D node->perms.num; --=20 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 From nobody Fri May 3 14:27:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1614350592; cv=none; d=zohomail.com; s=zohoarc; b=mgEbLZ7jXwmTe1PCwJXxO15DgHebd51FNSna96d8DkZ211/ADTm8zNtppBv606483SHC0ACd24018xf4HjAzIVH2HAeMd+XhbkJ8rUz6kJpYZxroSjCNydO5PpjsUehULMKNmyIFyPIhtvC2WPx1K60mK+mgw829Hyu+edPtYZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614350592; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PoZZTY1JhoFNyUyWnPJ+qOgbzP4vOc+deh5S5ccFoAU=; b=KX22qJE7+OuR3qvvcqJDtamVuO9dN6oP+h1Y/Cv0uK6XYve15ezE3t2Xf1xfHhkXumYm/wDtiQJpP2yJcFRSZ58CnHZ3z5Jk+AtScvPQrFPL5Abykv8Vj1dHp8lilXey1v0TyNlN51qG9Vf6arTe3Ncdz4+Wi4VJr2d4iZDDR6k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1614350592437582.9765346163647; Fri, 26 Feb 2021 06:43:12 -0800 (PST) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D NULL; int saved_errno; =20 + if (!connect_to) + return NULL; + h =3D malloc(sizeof(*h)); if (h =3D=3D NULL) goto err; --=20 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 From nobody Fri May 3 14:27:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1614350963; cv=none; d=zohomail.com; s=zohoarc; b=h+7FL2DMl9EwW9C0nQFBmRiGiAJeK7nHKlGm3SWv1xL1yXdU04M4jB15SCMM2aNU+6sbH3lsqsqWwo/O4hj9VC/A7tqc93s1s5khYg7YgpOseBI5PZyQqUIWnQJSO5n2YiyhfHdFNVpemLAVXMUYHf9cZgNjmBuEUZgpsGS5GFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614350963; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/ouoVhSElmsKf09bjsubId7QzwGwRxcvcchsYXzRAAQ=; b=nYvp3acgCKcvBf8QMKfArtW+p3yYcN0Tg3A2rQtiUDc89jPTlhC77SWULiFrNpKlZtIVP6BOmu+PYYpsLyQWWMC3NcM0QboRSauo/x59lfj0n3k2q49fU6HN/vzvxp+o8ySFYrBQm2f8tQjkhwTwYbkg3ZFMzKOmERS5kHE5PJY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1614350963600632.781982921065; Fri, 26 Feb 2021 06:49:23 -0800 (PST) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 ch= ar *child) bool xs_is_domain_introduced(struct xs_handle *h, unsigned int domid) { char *domain =3D single_with_domid(h, XS_IS_DOMAIN_INTRODUCED, domid); - int rc =3D strcmp("F", domain); + bool rc =3D false; + + if (!domain) + return rc; + + rc =3D strcmp("F", domain) !=3D 0; =20 free(domain); return rc; --=20 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879