From nobody Sat Apr 20 14:51:47 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1617736572; cv=none; d=zohomail.com; s=zohoarc; b=JqI9f4Tvm1akk4DdDKpmVO06eVoexy6xcsUFNsdK4teD3Ma5uzkSoE31NvkbqkG1Es4TTelvvNs1mzXX2ANSJPvwTCQfNrMSspnovgATs9MclFVA2x4mc1kzUGYg2qh4qZkUoe/Nk4KFrWXrIzYuvLai1bXbuMWau1t8rgGIahI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617736572; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=sDGEHF39zFGZyELm+jyFow2YFF3B1K268E33vzxWd5Y=; b=n0oc936TONCDh17km4uOC1u18qmczmvxGiEQv7NpG3H/rHq/uFhynNsIDSoBYyhESQcxsHh8Rt+4IOCoVG3ByCP1VQjmdm4b9CwBgbozgGhqZyNoGCimgKMQ45RKK1vLpfZ0RJPcdTeDNzT3oroZMzd/zv8tKSjRypqPRyjF1/k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16177365728861017.3565081728366; Tue, 6 Apr 2021 12:16:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.106262.203249 (Exim 4.92) (envelope-from ) id 1lTrB9-0003KI-Cx; Tue, 06 Apr 2021 19:15:59 +0000 Received: by outflank-mailman (output) from mailman id 106262.203249; Tue, 06 Apr 2021 19:15:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTrB9-0003KB-7t; Tue, 06 Apr 2021 19:15:59 +0000 Received: by outflank-mailman (input) for mailman id 106262; Tue, 06 Apr 2021 19:15:57 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTrB7-0003K1-Bl for xen-devel@lists.xenproject.org; Tue, 06 Apr 2021 19:15:57 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTrB7-0005WU-3h; Tue, 06 Apr 2021 19:15:57 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lTrB6-0000Jq-Qx; Tue, 06 Apr 2021 19:15:57 +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 Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From; bh=sDGEHF39zFGZyELm+jyFow2YFF3B1K268E33vzxWd5Y=; b=OZAnBc6X721bAtOGBshJa0Gn35 ucTToMYW/epkY2aYkW3tbv/iQK8CIjKQvS0H+19czmVzFNI8NcerV3ulXs+Kaf47SL5Gd23uNOi2F nKyOa34+cl1DWIf9vDR6NPsB1B/dpog5duo6ENwcBGe5H+0vPfulV6Bs/UOgy/Lt3IOA=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, Julien Grall Subject: [PATCH v2] xen/arm: kernel: Propagate the error if we fail to decompress the kernel Date: Tue, 6 Apr 2021 20:15:54 +0100 Message-Id: <20210406191554.12012-1-julien@xen.org> X-Mailer: git-send-email 2.17.1 X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall Currently, we are ignoring any error from perform_gunzip() and replacing the compressed kernel with the "uncompressed" kernel. If there is a gzip failure, then it means that the output buffer may contain garbagge. So it can result to various sort of behavior that may be difficult to root cause. In case of failure, free the output buffer and propagate the error. We also need to adjust the return check for kernel_compress() as perform_gunzip() may return a positive value. Take the opportunity to adjust the code style for the check. Signed-off-by: Julien Grall Reviewed-by: Michal Orzel --- Changes in v2: - Fix build --- xen/arch/arm/kernel.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index ab78689ed2a6..8f43caa1866d 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -292,6 +292,12 @@ static __init int kernel_decompress(struct bootmodule = *mod) iounmap(input); vunmap(output); =20 + if ( rc ) + { + free_domheap_pages(pages, kernel_order_out); + return rc; + } + mod->start =3D page_to_maddr(pages); mod->size =3D output_size; =20 @@ -503,7 +509,7 @@ int __init kernel_probe(struct kernel_info *info, =20 /* if it is a gzip'ed image, 32bit or 64bit, uncompress it */ rc =3D kernel_decompress(mod); - if (rc < 0 && rc !=3D -EINVAL) + if ( rc && rc !=3D -EINVAL ) return rc; =20 #ifdef CONFIG_ARM_64 --=20 2.17.1