From patchwork Fri Oct 4 16:56:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 175244 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp963699ill; Fri, 4 Oct 2019 09:58:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3nJGr7/jXMmkMDOs5NFkIvHWmFTQ6P41Wh2zqQp0P+OcX4ioYXsnHlbdET0F+nbgvInFi X-Received: by 2002:a92:451d:: with SMTP id s29mr17184591ila.228.1570208304244; Fri, 04 Oct 2019 09:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570208304; cv=none; d=google.com; s=arc-20160816; b=j4y9w6y3hzpQQJm8jCXAChV8hgxn/Njriyk89k95g+sVsMvgopXMO5jecVYmbow/D7 DNYlNLV1QDcUgHpdF68TjqN1sUKftHlpHrum7KesXD/xGzaoMnMT9noI3+etD8vB3sba XjtHNrv1xPYlfWVhisCOHlTwrQBSe6nI4DlgzaDD8VPbSA7vbwHPqbk3KRr3hiQzLIxJ I/xZzpnbcX8n+2jtH3U3QlAVPMB/1ynj1JCmb91YcwpmXtyEMmryhRz0aFyOQuPMEnRm kYBkdrrr+xCB8OJIkvkBMgr7GCvd53oUnFGG7A/LkVyghV5zVG/k14/+WqVCF3/5Se9A ZXig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:message-id:date:to:from; bh=+EqZcO2p05ZYj8NA66KZbaArNDifvJvbqspm2fizZ/s=; b=GEaMcyZ+iif8Rw91Ll9ECoymSDjqKUiLSrYevXMzbuBRnxXOYbcLvGmg/3KqYDJSj4 xEe59SnEsrXPRL1oZMMPrKwVZg4W8WlLhmQtOHJmxsOEy8nQxsd2Huw6HoMQQdLK4XUS 4+5Bf3bFOaFbgyvigc1JhM1EB3w7VEpYVgtWPfayCwuRQacepFM1SH8whGUFJDCMBq7q Ia3SNsz1Iy0LW7hebZy7t5KBbM4g3uH4LW9RLF2EDoVyJjcbV+hK2bGsUaQkwPVDOlz+ PJEirL54TnXqHAasT8licarhVo4jl5PKXXRx1OcVRmxPdZK/3MIol52m4C8z6uggoHF1 GIXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id i5si7960247jac.120.2019.10.04.09.58.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Oct 2019 09:58:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iGQsw-00044P-2L; Fri, 04 Oct 2019 16:56: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.89) (envelope-from ) id 1iGQsu-00044K-AW for xen-devel@lists.xenproject.org; Fri, 04 Oct 2019 16:56:52 +0000 X-Inumbo-ID: f5f769aa-e6c7-11e9-975d-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id f5f769aa-e6c7-11e9-975d-12813bfff9fa; Fri, 04 Oct 2019 16:56:51 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E4EBF15AB; Fri, 4 Oct 2019 09:56:50 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3B5EA3F68E; Fri, 4 Oct 2019 09:56:50 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 4 Oct 2019 17:56:46 +0100 Message-Id: <20191004165646.14482-1-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 Subject: [Xen-devel] [PATCH for-4.13] xen/xsm: flask: Check xmalloc_array() return in security_sid_to_context() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: jgross@suse.com, Julien Grall , Daniel De Graaf MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" xmalloc_array() may return NULL if there are memory. Rather than trying to deference it directly, we should check the return value first. Coverity-ID: 1381852 Signed-off-by: Julien Grall Acked-by: Daniel De Graaf --- xen/xsm/flask/ss/services.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/xsm/flask/ss/services.c b/xen/xsm/flask/ss/services.c index b59928ea8a..42686535f2 100644 --- a/xen/xsm/flask/ss/services.c +++ b/xen/xsm/flask/ss/services.c @@ -775,6 +775,8 @@ int security_sid_to_context(u32 sid, char **scontext, u32 *scontext_len) *scontext_len = strlen(initial_sid_to_string[sid]) + 1; scontextp = xmalloc_array(char, *scontext_len); + if ( !scontextp ) + return -ENOMEM; strlcpy(scontextp, initial_sid_to_string[sid], *scontext_len); *scontext = scontextp; goto out;