From patchwork Mon Nov 23 07:43:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 57113 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1280358lbb; Sun, 22 Nov 2015 23:45:53 -0800 (PST) X-Received: by 10.66.235.40 with SMTP id uj8mr34709749pac.151.1448264752937; Sun, 22 Nov 2015 23:45:52 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id x8si18078332pbt.193.2015.11.22.23.45.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Nov 2015 23:45:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a0lnY-0004Rn-7V; Mon, 23 Nov 2015 07:44:28 +0000 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a0lnI-0004IS-4f for linux-arm-kernel@lists.infradead.org; Mon, 23 Nov 2015 07:44:14 +0000 Received: by wmuu63 with SMTP id u63so42212308wmu.0 for ; Sun, 22 Nov 2015 23:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V8lXTl/dGCQ18Q2rHFlN4208AuDb1adr+HtMvJASU+0=; b=rTNlih0lOOUbGXdgDLUvH5B4bQOvrk4wrQyyKhCP7iPBWPvV32c+ybqSkppQrCxztn ThSB3YP9mU+CxqLuGexfiXwfuCHrKrBcc/afXVxvVXx2tcsPrSiSOJLNHyhgxDBv0BNG SolfN/BDGKqAB+HDOmazx/4BrhFpDBlcMuPgQKWas08tfLyEbjmJERk+fNHiLelTNpwP VEznZLlPn5AfFaL3/yDaT37C3d3MtyttQaSGtdzF225qkQehQ9mjNYn1d6cEiKgqpCSa lSHsVrfODYjHyRf9mrEh3rCdyQM5a/DavLNQ+GkXu4ins77OErei1ZJ9/tNMQic3onv+ tIyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V8lXTl/dGCQ18Q2rHFlN4208AuDb1adr+HtMvJASU+0=; b=jRczvboBGdMy7qPLbbMPgqUMI3WfwQy8T+PgCvHVBSIIXc5XPDvXuIiwV3CjyHihxr 1T3kGuH6BjpprhLWi2UjLqQMDbSg9g1PKJPvB3155PWSeaNPW84CVO2nNE/wFDDkPFr2 zvxkTfKQEzJIl8K2prSsp+s46dsBdYFf1uvnIU0ydbGW7cgszNAghb47wxLqGHKQMQAM GafeSrWkKvDky9dnnzpEbPlefVKYVRBlUrGTxEZwRme2HKh+H0pZsx1rF45no8PgNtCK nqOSwaHDwUQoF0mTHpszHCpW9gmkA9UEISPrkodDS3zvrOI23m/4wcj5RxntIpT+Q/7G hkDQ== X-Gm-Message-State: ALoCoQkWMl7Kd37g6AJcSQjsWDxwVV2OEZoEISfDM7N2vKvjXrpIhkiXglR/cB8fw2vq1MDmslEq X-Received: by 10.195.11.233 with SMTP id el9mr9907086wjd.145.1448264630225; Sun, 22 Nov 2015 23:43:50 -0800 (PST) Received: from localhost.localdomain ([2.44.140.166]) by smtp.gmail.com with ESMTPSA id cw3sm11853548wjb.26.2015.11.22.23.43.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Nov 2015 23:43:49 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, leif.lindholm@linaro.org Subject: [PATCH 1/2] arm64/efi: deal with NULL return value of early_memremap() Date: Mon, 23 Nov 2015 08:43:23 +0100 Message-Id: <1448264604-19411-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448264604-19411-1-git-send-email-ard.biesheuvel@linaro.org> References: <1448264604-19411-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151122_234412_468258_32A128AA X-CRM114-Status: GOOD ( 14.27 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:236 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: matt@codeblueprint.co.uk, linux@arm.linux.org.uk, will.deacon@arm.com, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Add NULL return value checks to two invocations of early_memremap() in the UEFI init code. For the UEFI configuration tables, we just warn since we have a better chance of being able to report the issue in a way that can actually be noticed by a human operator if we don't abort right away. For the UEFI memory map, however, all we can do is panic() since we cannot proceed without a description of memory. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/efi.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index fc5508e0df57..186b9e119d4a 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -127,7 +127,11 @@ static int __init uefi_init(void) table_size = sizeof(efi_config_table_64_t) * efi.systab->nr_tables; config_tables = early_memremap(efi_to_phys(efi.systab->tables), table_size); - + if (config_tables == NULL) { + pr_warn("Unable to map EFI config table array.\n"); + retval = -ENOMEM; + goto out; + } retval = efi_config_parse_tables(config_tables, efi.systab->nr_tables, sizeof(efi_config_table_64_t), NULL); @@ -209,6 +213,14 @@ void __init efi_init(void) PAGE_ALIGN(params.mmap_size + (params.mmap & ~PAGE_MASK))); memmap.phys_map = params.mmap; memmap.map = early_memremap(params.mmap, params.mmap_size); + if (memmap.map == NULL) { + /* + * If we are booting via UEFI, the UEFI memory map is the only + * description of memory we have, so there is little point in + * proceeding if we cannot access it. + */ + panic("Unable to map EFI memory map.\n"); + } memmap.map_end = memmap.map + params.mmap_size; memmap.desc_size = params.desc_size; memmap.desc_version = params.desc_ver;