From patchwork Wed Feb 10 17:55:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 61690 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp2789922lbl; Wed, 10 Feb 2016 09:56:50 -0800 (PST) X-Received: by 10.98.7.219 with SMTP id 88mr60400305pfh.49.1455127009336; Wed, 10 Feb 2016 09:56:49 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id f83si6401273pfd.208.2016.02.10.09.56.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Feb 2016 09:56:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for 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: best guess record for 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 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 1aTYzS-0004xg-3m; Wed, 10 Feb 2016 17:55:46 +0000 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTYzG-0004uC-JR for linux-arm-kernel@lists.infradead.org; Wed, 10 Feb 2016 17:55:35 +0000 Received: by mail-wm0-x229.google.com with SMTP id p63so37265894wmp.1 for ; Wed, 10 Feb 2016 09:55:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GopgIHpkL+ihWxHMaHHtS7Qk4z/k3H2Dbrzg+d20Jno=; b=WXBFd0vjrq9+pdEs2ZPH0ttLLJhApUcO9Gr29GUJLRUo33tENq+5V1rtknuRH1YjLz WTpiAlc23iP9y9KRvkheV+vw4pGLfj6pBNOZVhg0JYZRMW/XTYAMUReTdxlbnI5mGXkL /uDkFP/Ac4dYGLQsNHsvY555/0U+43I63waVQ= 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=GopgIHpkL+ihWxHMaHHtS7Qk4z/k3H2Dbrzg+d20Jno=; b=MBojRZjnysMgldfjpPlrKdh3CvHlt28ut/HexaZk+Bq1RcBMKNrp9VFMkRG3VlrlHL ytQSVptsJZjUxtIdGLiEzTTfT+13QWpzEMVT/aMC9idoZ9JssInUQMAS4QZ3qRw+YOxD 1apRDJeUwqx12+UDf2EkmfLAjzwHPjdE8bQKjVAMfpa80CFDVgQbGnD3S1Iq8YgFcAXP Imy1uVRbtzQpOAzZ3RuO7bWLAwRra3eFnxyyieVU3QGfGaNJnVg0AOZDYQdn0fu6LI3u bAifW1BDNQ8v/Fghdzyj4UQhkUqJzYcKLe6r1ncIwkejtaPyaiLnto80odyEs/fsEILu rbbw== X-Gm-Message-State: AG10YOSIXHl6XcMRh+8yfpqLrzhOXagSOWSV+z10DrSlD7NYQVJE5aahZUy5v3b1HO+cbhkj X-Received: by 10.194.133.233 with SMTP id pf9mr41872338wjb.75.1455126916530; Wed, 10 Feb 2016 09:55:16 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id jo6sm3942695wjb.48.2016.02.10.09.55.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Feb 2016 09:55:15 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, keescook@chromium.org, linux-efi@vger.kernel.org, matt@codeblueprint.co.uk, mark.rutland@arm.com Subject: [PATCH v5sub3 3/4] efi: stub: use high allocation for converted command line Date: Wed, 10 Feb 2016 18:55:04 +0100 Message-Id: <1455126905-22688-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455126905-22688-1-git-send-email-ard.biesheuvel@linaro.org> References: <1455126905-22688-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160210_095534_858282_D773062B X-CRM114-Status: GOOD ( 12.41 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -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_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Before we can move the command line processing before the allocation of the kernel, which is required for detecting the 'nokaslr' option which controls that allocation, move the converted command line higher up in memory, to prevent it from interfering with the kernel itself. Since x86 needs the address to fit in 32 bits, use UINT_MAX as the upper bound there. Otherwise, use ULONG_MAX (i.e., no limit) Reviewed-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- arch/x86/include/asm/efi.h | 2 ++ drivers/firmware/efi/libstub/efi-stub-helper.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 0010c78c4998..08b1f2f6ea50 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -25,6 +25,8 @@ #define EFI32_LOADER_SIGNATURE "EL32" #define EFI64_LOADER_SIGNATURE "EL64" +#define MAX_CMDLINE_ADDRESS UINT_MAX + #ifdef CONFIG_X86_32 diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index f07d4a67fa76..29ed2f9b218c 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -649,6 +649,10 @@ static u8 *efi_utf16_to_utf8(u8 *dst, const u16 *src, int n) return dst; } +#ifndef MAX_CMDLINE_ADDRESS +#define MAX_CMDLINE_ADDRESS ULONG_MAX +#endif + /* * Convert the unicode UEFI command line to ASCII to pass to kernel. * Size of memory allocated return in *cmd_line_len. @@ -684,7 +688,8 @@ char *efi_convert_cmdline(efi_system_table_t *sys_table_arg, options_bytes++; /* NUL termination */ - status = efi_low_alloc(sys_table_arg, options_bytes, 0, &cmdline_addr); + status = efi_high_alloc(sys_table_arg, options_bytes, 0, + &cmdline_addr, MAX_CMDLINE_ADDRESS); if (status != EFI_SUCCESS) return NULL;